Examples of L TEX
Examples of L TEX
Contents
1. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1
2. First Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3. Set Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
4. Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
5. Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
6. Tables, Diagrams, Tests, Other . . . . . . . . . . . . . . . . . 11
7. Pictures (ESP files) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
8. Maple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
9. Calligraphic and Blackboard Bold Fonts . . . . . . . . 22
10. PDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
11. Some LATEX and AMS symbols . . . . . . . . . . . . . . . 23
12. More symbols and graphics . . . . . . . . . . . . . . . . . . . 27
0
1 Introduction
TEX is a computer typesetting program (a markup language) invented by
Donald Knuth, and is used by the American Mathematical Society to typeset
all of the Society’s publications. In order to use raw TEX one must learn a lot
about the TEX programming language. To simplify the use of TEX, several
programs were written in theTEX language which are easier to use than TEX
itself. The most successful of these were LATEX and AMS-LATEX. These have
now been put into the public domain and combined into a single program
called LATEX2e.
One can learn a lot about LATEX simply by observing examples of its
use. The purpose of this pamphlet is to give some examples. Most of the
examples appear in the following form: the printed (output) version is given
first, marked by a bullet. Immediately following that is the LATEX code that
produced the printed version. If an example takes a full page, we have not
used the bullet. The superscripts (e.g., {L: 21, 77} ) following the lines with
bullets are relevant page numbers in the reference manual “LATEX” by Leslie
Lamport, and should not be confused with footnotes. The examples were
liberated from a variety of sources.
Most of the examples given below were created in the older LATEX. The
main difference, as far as these examples are concerned, is that old LATEX
files started with “\documentstyle” and LATEX2e uses “\documentclass.”
Another difference is that over time new mathematical symbols were made
available by the AMS for LATEX. Most of our examples were written before
AMS symbols were available, and some tricks were used to obtain a few
symbols that now are available from the AMS collection. Use of the AMS
symbols requires putting in the header “\usepackage{amssymb}” following
“\documentclass{article}”. Tables of LATEX and AMS symbols are given
in §11. N.B: The sample theses in UNCG ThesisPackage were written in
the older LATEX. Instead of “\usepackage{amssymb}”, use something like
“\documentstyle[amssymb,stmaryrd,graphicx,epsfig]{uncgthesis}”.
You may not need all of these options.
The stardard reference book for LATEX2e is “A Guide to LATEX2e, Doc-
ument Preparation for Beginners and Advanced Users,” by Helmut Kopka
and Patrick W. Daly. The earlier reference book “LATEX User’s Guide &
Reference Manual” by Leslie Lamport, is still usable.
1
2 First Steps
{L: 9}
• Hello world!
\documentclass{article}
\begin{document}
Hello world!
\end{document}
2
• Who proved Pospı́šil’s theorem, Arhangel0 skiı̆ or Erdös? {L: 40}
3 Set Theory
{L: 15, 44}
• Ac = {x ∈ X : x ∈
/ A}
$A^{c} = \{x\in X: x\not\in A\}$
{L: 44}
• A ∩ Ac = ∅
$A\cap A^{c}=\emptyset$
{L: 44}
• A ∪ Ac = X
$A\cup A^{c}=X$
{L: 44}
• f :X→B
$f:X \rightarrow B$
• ∀x, y ∈ IR
3
$\forall x,y \in {\rm I\kern-.2em R}$
3
Use in the unlikely event your TeX does not have AMS Blackboard Bold font.
3
•
F r∗ (ℵα , α) ⇔Def ∀F : [ℵα ]<ω → ℵα ∃hxi |i < αi ∀i<αxi ∈ [ℵi , ℵi+1 ) ∧ xi 6∈ F 00 {xj |j 6= i}.}
$$B= \prod_{\xi\leq\alpha}U_\xi\times\prod_{\alpha<\xi<\om}X_\xi$$
•
[
Add(I) = {X ⊆ ω ω : (∀ Borel D ⊆ ω ω ×2ω )(∀x ∈ X) Dx ∈ I ⇒ Dx ∈ I}.
x∈X
\[Add({\mathcal I})=\{X\subseteq\omega^\omega:
(\forall\hbox{ Borel }D\subseteq\omega^\omega\times 2^\omega)
(\forall x\in X)\ D_x\in {\mathcal I}\ \Rightarrow
\bigcup_{x\in X}D_x\in {\mathcal I}\}.\]
• Is clβω or ω* an extremally disconnected space?
Is clβω or ω* an extremally disconnected space?{L: 55−57}
\newcommand{\clbw}{\mbox{$cl_{\beta\omega}$}}
\newcommand{\ed}{extremally disconnected}
\newcommand{\wstar}{\mbox{$\omega$*}}
Is \clbw\ or \wstar\ an \ed\ space?
Is $\clbw$ or $\wstar$ an \ed\ space?
∀x1 ∃x2 (R(x1 , x2 )∨(x1 = x2 )) → (∀x2 ∃x1 (x1 6= x2 ) → ∀x1 ∃x2 (R(x1 , x2 )∨(x1 = x2 )).
4
The double dollar $$· · ·$$ delimiters make the formula print as a displayed formula.
The delimiters \[ · · · \] may be used instead.
4
Prove that the following formula is a tautology of $FO_L$
$$\forall x_1\exists x_2(R(x_1,x_2)\vee (x_1 = x_2))
\rightarrow (\forall x_2 \exists x_1 (x_1 \not= x_2)\rightarrow
\forall x_1\exists x_2(R(x_1,x_2)\vee (x_1 = x_2)).$$
4 Algebra
Pn−1 i
• A formula P (x) = i=0 ai xq in line.{L: 45}
5
displayed.
Same formula
\[P(x) = \sum _{i=0}^{n-1}a_ix^{q^{i}}\]
displayed.
• xn − 1 = (x − α1 )(x − α2 ) · · · (x − αk )g(x).
$x^n - 1 = (x - \alpha_{1})(x - \alpha_{2}) \cdots(x - \alpha_{k})g(x)$.
a/([w]∼k ,a )
• The formulas are represented by the diagram: [w]∼k −→ [wa]∼k .{L: 45, 52}
\[B_i = \left\{\begin{array}{ll}
-A_{s,\, k+1} & \mbox{if }i = (k+1) -2s\\
A_{s-1,\, k} & \mbox{if }i = (k+2) - 2s\end{array}\right.\]
5
•
{L: 49}
s k+1−s k+1−s−1
(−1) +
s−1 s−2
6
\[V = \left[\begin{array}{ccccc}
1 & x_1 & x_1^2 & \cdots & x_1^{n-1}\\
1 & x_2 & x_2^2 & \cdots & x_2^{n-1}\\
\vdots & \vdots & \vdots & &\vdots\\
1 & x_n & x_n^2 & \cdots &x_n^{n-1}\end{array}\right]\]
•
1,...,n
X
f= x̄h ahj xj , ajh = āhj
h,j
7
5 Analysis
{L: 46}
• f (x) = arcsin(ln x)
$f(x) = \arcsin(\ln x)$
• sinh x2 − cosh2 x = 1
$\sinh x^2 - \cosh^2 x = 1$
R 6x−11 {L: 42, 46, 170}
• x2 −2x−1
$\int \frac{6x - 11}{x^2 - 2x - 1}$
6x − 11 {L: 54, 172, 201}
Z
•
x2 − 2x − 1
$\displaystyle\int \frac{\textstyle 6x - 11}{\textstyle x^2 - 2x - 1}$
ln( 13 )
• t= 1
ln( 23 )
5
$t = \frac{\ln(\frac{1}{3})}{\frac{1}{5}\ln(\frac{2}{3})}$
ln( 13 )
• t= 1
5
ln( 23 )
$\displaystyle t = \frac{ \ln(\frac{1}{3})}{\frac{1}{5}\ln(\frac{2}{3})}$
R 1 √x2 − 1 {L: 42, 52, 170}
• 0 x dx
$\int_0^1 \frac{\textstyle \sqrt{x^2 - 1}}{\textstyle x}\, dx$
Z 1√ 2
x −1
• dx
0 x
$\displaystyle\int_0^1 \frac{\textstyle \sqrt{x^2 - 1}}
{\textstyle x}\, dx$
r
2
• y = ln 3 x2 − 1
x +1
$y = \ln \sqrt[3]{\frac{\textstyle x^2 - 1}{\textstyle x^2 + 1}}$
22
• a + b + · · · +y + z
z}|{
| {z }
26
$\underbrace{a+b+\overbrace{\cdots}^{22}+y+z}_{26}$
8
• f = g ◦ h.
$f = g\circ h$.
•
0 if x is rational
f (x) = {L: 51}
1 if x is irrational
\[f(x) = \left\{\begin{array}{ll}
0 & \mbox{if $x$ is rational}\\
1 & \mbox{if $x$ is irrational}\end{array}\right.\]
•
dx
+ u2 du = 0
Z x Z Z
dx 2
+ u du = 0dx
x
u3
ln |x| + = C
3
1 y
ln |x| + ( )3 = C, or
3 x
3x ln |x| + y 3 = Cx3 .
3
\begin{eqnarray*}
\frac{dx}{x} + u^2du & = & 0\\
\int \frac{dx}{x} + \int u^2du & = & \int 0dx\\
7
Note the difference between centered dots and low dots
9
\ln|x| + \frac{u^3}{3} & = & C \\
\ln|x| + \frac{1}{3}(\frac{y}{x})^{3}& = & C, \mbox{ or} \\
3x^3\ln|x| + y^3& = & Cx^3. \end{eqnarray*}8
• hence we have:
dw
e−3x − 3e−3x = −3e−3x e3x
dx
d −3x
e w = −3
Zdx Z
−3x
d e w = −3dx
e−3x w = −3x + C
w = −3xe3x + Ce3x
10
sin x cos h + cos x sinh − sin x
= lim
h→0
h
sin x(cos h − 1) sin h
= lim + cos x
h→0 h h
= cos x
\begin{eqnarray*}
\frac{d}{dx} \sin x & = & \lim_{h\rightarrow0}\frac{\sin(x+h)-\sin x}{h}\\
& = & \lim_{h\rightarrow0}\frac{\sin x\cos h + \cos x\sinh - \sin x}{h}\\
& = & \lim_{h\rightarrow0}\frac{\sin x(\cos h-1)}{h}
+ \cos x\frac{\sin h}{h}\\
& = & \cos x
\end{eqnarray*}
11
• Here is a way to get one of those “end of proof boxes.”
\newcommand{\qed}{\mbox{}\nolinebreak\hfill\fbox{}\medbreak\par}
Here is a way to get one of those "end of proof boxes."\qed
• Exercise 5.2
Since we must prove the biconditional (∀x)Bx ↔ Ba, we prove each of the
two associated conditionals one at a time. First we prove Ba → (∀x)Bx; so
we assume Ba:
Exercise 5.2
\begin{tabbing}
1. $(\forall x)(Ax\rightarrow Bx)$\hspace{.3in}\= Premise\\
2. $(\forall y)(B_y\rightarrow(\forall x)Ax)$ \> Premise\\
\end{tabbing}
\vspace{-.2in}
Since we must prove the biconditional $(\forall x)Bx\leftrightarrow
Ba$, we prove each of the two associated conditionals one at a
time. First we prove
$Ba\rightarrow(\forall x)Bx$; so we assume $Ba$:
\begin{tabbing}
3. $Ba$\hspace{1.05in}\= Premise for CP ($a$ is a constant; so not
flagged)\\
4. $Ba\rightarrow(\forall x)Ax$ \> 2, US $[a|y]$\\
5. $(\forall x)Ax$\> 3,4 T\\
6. $Ax$\>5, US $[x|x]$
\end{tabbing}
12
• Rook’s combinatorial equation in a line of text, x2 + 3x + 1 = .
This is a kludge, but may be adequate for handouts. First, I defined a square
making macro \sq(n,m) where the n,m are used to position the square. I
used trial and error to put the squares together in various patterns, and to
place the big parentheses.
\def\sq(#1,#2){\put(#1,#2){\setlength{\unitlength}{.25cm}
\put(1,0){\line(0,1){1}} % left
\put(2,0){\line(0,1){1}} % right
\put(2,0){\line(-1,0){1}} % bottom
\put(2,1){\line(-1,0){1}} % top
}}
Rook’s combinatorial equation in a line of text, $x^2+3x+1=
\Big(\hspace{-23pt}\vcenter{\begin{picture}(0,20)(0,0)
\sq(3,3)\sq(10,10)\sq(17,3)
\end{picture}}\hspace{-305pt}\vcenter{\Big)}$.
This is a kludge, but may be adequate for handouts. First, I
defined a square making macro \verb@\sq(n,m)@ where the n,m are used
to position the square. I used trial and error to put the squares
together in various patterns, and to place the big parentheses.
13
14
x
(b) y =
ln |x|
sin x − 1
Z
(b) dx
cos x
15
\bigskip
Show your work for credit.\hspace{1in}Name\hrulefill
\bigskip
1. (30) For the following functions,
find $ \frac{\textstyle dy}{\textstyle dx}$
\medskip
b d
Diagram 2
\def\ccc{{\spfont ccc}}
\def\infsets{[\omega]^\omega}
\def\functs{{}^\omega\omega}
\def\pow#1{{\mathcal P}(#1)}
\def\almsub{\mathbin{\subset^*}}
\def\lemodfin{\mathbin{\le^*}}
\def\rng{\mathop{\rm rng}\nolimits}
\def\dom{\mathop{\rm dom}\nolimits}
16
\def\cont{${\bf c}$} %use this is Frakture is not available
\def\frb{${\bf b}$} %ditto
\def\frd{${\bf d}$} %ditto
\begin{figure}[ht]
\begin{center}
\begin{picture}(400,160)(-25,-25)
%caption:
\thingy(175,-25){{\rm Diagram~2}}
\thingy(0,0){$\aleph_1$}
\thingy(\xnit,0){$\add(\Leb)$}
\thingy(\xnita,0){$\add(\Kat)$}
\thingy(\xnitb,0){$\cov(\Kat)$}
\thingy(\xnitc,0){$\nonn(\Leb)$}
\thingy(\xnita,\ynit){$\bf b$}
\thingy(\xnitb,\ynit){$\bf d$}
\thingy(\xnit,\dynit){$\cov(\Leb)$}
\thingy(\xnita,\dynit){$\nonn(\Kat)$}
\thingy(\xnitb,\dynit){$\cff(\Kat)$}
17
\thingy(\xnitc,\dynit){$\cff(\Leb)$}
\thingy(\xnitd,122){$\cont$}
%edges
%horizontal units:
\def\hnit{30}
%vertical units:
%height of bottom lines and toplines
\def\blh{5} \def\tlh{125}
%lengths of vertical lines
\def\btot{100} %bottom to top
\def\btoh{40} %bottom to half
\def\htot{45} %half to top
\end{picture}
\end{center}
\end{figure}
18
The next example illustrates use of minipage.
•
CALL FOR PAPERS
Ninth Annual IEEE Symposium on
Program Chair: The LICS symposia aim to attract high quality orig-
John Smith inal papers covering theoretical and practical issues
Attn: LICS in computer science that relate to logic in a broad
Department of Computing sense, including algebraic, categorical and topologi-
Imperial College cal approaches.
180 Queen’s Gate Suggested, but not exclusive, topics of interest in-
London SW7 2BZ clude: abstract data types, automated deduction, con-
United Kingdom currency, constructive mathematics, data base the-
[email protected] ory, knowledge representation, lambda and combina-
Phone: (44) 71-589-5111 tory calculi, logical aspects of computational complex-
Fax: (44) 71-581-8024 ity, logics in artificial intelligence, logic programming,
modal and temporal logics, program logic and seman-
tics, rewrite rules, logical aspects of symbolic comput-
ing, problem solving environments, software specifica-
tion, type systems, verification.
19
\documentstyle{article}
\topmargin-0.75in
\marginparwidth 0pt \oddsidemargin 0pt \evensidemargin 0pt
\marginparsep 0pt
\textwidth 6.5in \textheight 10.0in\parskip 6pt \parindent 0pt
\renewcommand{\i}[1]{{\it #1 \/}}
\begin{document}
\thispagestyle{empty}
\begin{center}
{\bf CALL FOR PAPERS}\\[2ex]
{\large Ninth Annual IEEE Symposium on }\\[2ex]
{\Large\bf LOGIC IN COMPUTER SCIENCE }\\[2ex]
{\large\it July 4--7, 1994, Paris, France}
\end{center}
\vspace{.2in}
\small
\begin{minipage}[t]{2.00in}% first column
\parskip 4pt
{\bf Program Chair:} \\[1mm]
John Smith\\
Attn: LICS \\
Department of Computing\\Imperial College\\
180 Queen’s Gate\\London SW7 2BZ\\United \medskip Kingdom\\
{\tt [email protected]}\\
Phone: (44) 71-589-5111\\
Fax: (44) 71-581-8024 \\
\end{minipage}\hskip .20 in
\begin{minipage}[t]{3.5in}% second column%
\parskip 4pt
The {\bf LICS} symposia aim to attract high quality original papers
covering theoretical and practical issues in computer science that
relate to logic in a broad sense, including algebraic, categorical and
topological approaches.
20
7 Pictures (ESP files)
We give an example of how to place an ESP (Encapsulated PostScript) file into a
LATEX document. It should be noted, however, that this feature depends on the
LATEX package installed on your computer. Whether or not a figure will show in
your TEX previewer, or print on paper depends on whether your LATEX package
has the necessary screen or print drivers (these drivers are not part of basic LATEX).
To use the method in this example, the graphic file should be an EPS file.
Other graphic files, such as JPEG files, may not work using the code below 9 .
Possibly the graphics program used to make your figure or picture can save your
file as EPS. If not, there are a number of programs that will convert graphic files
to an ESP file. For example, in unix, one may use gimp or xv, or one may convert
the file using Photoshop. Be aware that EPS files tend to be large.
Here is how we put the rather simple graphic file “pedals.eps” (file size 40K)
in this document.
Figure 1: Pedals
\begin{figure}[h]
\centerline{\epsfbox{pedals.eps}}
\caption{Pedals}
\label{twopetals}
\end{figure}
9
The program TeXShop for Macintosh OS X, works with JPEG files, but not ESP files!
21
8 Calligraphic and Blackboard Bold Fonts
LATEX includes twenty six upper case letters in a special type style called Calli-
graphic. Calligraphic letters have been used several times in the previous examples.
For example, A, B, C, · · · . The previous sentence is obtained by typing
There are twenty six uppercase letters in Blackborad Bold type style, Black-
board bold is not a part of LATEX, but is included with \usepackage{amssymb}.
For example, the symbols Z and R are often used to denote the set of integers
and the set of real numbers, respectively. Conside the following example:
• Recall N ⊂ Z ⊂ Q ⊂ R.
Recall $\mathbb N\subset\mathbb Z\subset \mathbb Q\subset \mathbb R$.
Other fonts are discussed in the book by Kopka and Daily mentioned in §1.
9 Maple
One can also produce LATEX code from Maple. For example the Maple code
latex(Limit(4*x^5+sin(x)^2, x=0,right));
which produces
limx→0+ 4 x5 + (sin(x))2
when printed using LATEX, but we do not pursue this here (see Maple Help).
10 PDF
How can you sent electronically a TEX manuscript to someone who may not have
TEX or who may not have all the drivers that you have for displaying pictures
and other graphics files? A good alternative is to send instead a PDF (portable
document format) file. Some government agencies and journals require submission
of manuscripts in PDF.
In Macintosh OS X, PDF files are automatic or immediately avaliable. For
Windows and others, once you have your TEX file, use it to produce a postscript
file (e.g., dvips), and then use a program to convert a postscript file to a PDF
22
file. There are many programs that can do this conversion. One that is free is
the program “GhostScript”. When you have GhostScript running, use the internal
program called “ps2pdf.” This will convert your .ps file to a .PDF file, and anyone
with Adobe Acrobat
c Reader can then read and print your PDF file in all its
glory (assuming your TEXpackage had the necessary drivers to start with).
Miscellaneous symbols
† \dag ‡ \ddag § \S
c \copyright
¶ \P # \# % \% \_
{ \{ } \}
23
Binary operators (math mode)
† \dag § \S
c \copyright
¶ \P £ \pounds # \#
$ \$ % \% & \&
\_ { \{ } \}
24
Relations (math mode)
( ( ) ) [ [
] ] { \{ } \}
b \lfloor c \rfloor d \lceil
e \rceil h \langle i \rangle
\ \backslash | \vert k \Vert
↑ \uparrow ⇑ \Uparrow \blacksquare
↓ \downarrow ⇓ \Downarrow l \updownarrow
m \Updownarrow p \ulcorner q \urcorner
x \llcorner y \lrcorner / /
25
AMS Arrows (math mode; requires package{amssymb})
26
AMS Binary Operators (math mode; requires package{amssymb})
u \dotplus n \ltimes r \smallsetminus
o \rtimes e \Cap d \Cup
i \rightthreetimes h \leftthreetimes Z \barwedge
Y \veebar f \curlywedge g \curlyvee
[ \doublebarwedge \boxminus \boxdot
\boxtimes \boxplus ~ \circledast
\circleddash } \circledcirc > \divideontimes
| \intercal \centerdot
AMS Miscellaneous Symbols (math mode; requires package{amssymb})
~ \hbar 8 \backprime } \hslash
∅ \varnothing M \vartriangle O \triangledown
\square ♦ \lozenge s \circledS
N \blacktriangle H \blacktriangledown \blacksquare
\blacklozenge F \bigstar ∠ \angle
^ \sphericalangle ] \measuredangle @ \nexists
{ \complement ð \eth ` \Finv
\diagup \diagdown a \Game
k \Bbbk \restriction
AMS Negative relations (math mode; requires package{amssymb})
≮ \nless ≯ \ngtr \nleq
\ngeq
\nleqslant \ngeqslant
\nleqq \ngeqq \lneq
\gneq \lneqq \gneqq
\lvertneqq \gvertneqq \lnsim
\gnsim \nsucceq \precnsim
\succnsim \precnapprox \succnapprox
\lnapprox \gnapprox \npreceq
\nsim \ncong . \nshortmid
/ \nshortparallel - \nmid ∦ \nparallel
0 \nvdash 2 \nvDash 1 \nVdash
3 \nVDash 6 \ntriangleleft 7 \ntriangleright
5 \ntrianglelefteq 4 \ntrianglerighteq * \nsubseteq
+ \nsupseteq " \nsubseteqq + \nsupseteq
( \subsetneq ) \supsetneq \varsubsetneq
! \varsupsetneq $ \subsetneqq ) \supsetneq
\precneqq \succneqq ⊀ \nprec
\nsucc & \varsubsetneqq ' \varsupsetneqq
27
are discussed in “A Guide to LATEX2e, Document Preparation for Beginners and
Advanced Users,” by Helmut Kopka and Patrick W. Daly.
Recently, one of our master’s students needed a symbol not in the above lists
in §11. He needed a two headed arrow with the arrow pointing upward and a two
headed arrow with the arrow pointing downward. Two headed arrows pointing to
the left and right are available in the list AMS Arrows (math mode), but none
of the list in §11 have the symbols he needed. To get the desired symbols, the
student used a “rotate command” in the graphicx package to rotate the left and
right two headed arrows by 270 degrees. He put in his preamble
\newcommand{\Lower}{\rotatebox[origin=c]{270}{$\twoheadrightarrow$}}
\newcommand{\Upper}{\rotatebox[origin=c]{270}{$\twoheadleftarrow$}}.
He used the commands $\Lower$ and $\Upper$ to produce the desired symbols.
• Also A = y so x v a << y.
Also $A = \Lower y$ so $x\sqsubseteq a << y$.
A problem that may occur is that some TeX previewers may not show the
rotated symbol correctly. They may show the (unrotated) symbol unchanged,
or higher on the line or lower on the line. Again this is a problem with the
drivers. The rotated symbol should print correctly (to paper or to a PDF file) and
the Windows previewer “dviout” (download from www.ctan.org) should show the
rotated symbols correctly.
28