TeX notes

From w
Jump to: navigation, search

This is a personalized note and reminder regarding TeX uses.

General

My template

Change the path after the \input command if necessary.

Can use for amsbook. Remove Korean language support if not needed.
braids, coffee stain styles.

Good source of examples

http://en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics

Reference management

  • Open Chrome, go to MathSciNet, open an author, copy and paste all in BibTeX format onto BibDesk.
  • Separately download papers into Papers for Mac.

Colors

https://en.wikibooks.org/wiki/LaTeX/Colors

PDF insertion

\includepdf[pages={1-}]{pdf-file.pdf}

Version control

LaTeX Diff

latexdiff --flatten /path/to/old/version/main.tex main.tex > diffs.tex

Preliminary version only

Put in the main file.

\usepackage[notref,notcite]{showkeys}
\usepackage{showlabels,prelim2e}

Symbols

Limits below operators

\bigcap_{n\ge0} A_n

\(\bigcap_{n\ge0} A_n\)

  • \(\cup\) for binary, \(\bigcup\) for ternary or more. (ref. G&T Editorial)

Grammar

Matrices

matrix (no paranthesis), pmatrix, bmatrix (bracket; typical), Bmatrix (brace), vmatrix (single bar), Vmatrix (double bar), and smallmatrix (often inline).

\[ \begin{matrix} a & b \\ c & d\end{matrix}, \begin{pmatrix} a & b \\ c & d\end{pmatrix}, 
\begin{bmatrix} a & b \\ c & d\end{bmatrix}, \begin{Bmatrix} a & b \\ c & d\end{Bmatrix}, 
\begin{vmatrix} a & b \\ c & d\end{vmatrix}, \begin{Vmatrix} a & b \\ c & d\end{Vmatrix}, 
\begin{smallmatrix} a & b \\ c & d\end{smallmatrix}. \]

\(\begin{matrix} a & b \\ c & d\end{matrix}, \begin{pmatrix} a & b \\ c & d\end{pmatrix}, \begin{bmatrix} a & b \\ c & d\end{bmatrix}, \begin{Bmatrix} a & b \\ c & d\end{Bmatrix}, \begin{vmatrix} a & b \\ c & d\end{vmatrix}, \begin{Vmatrix} a & b \\ c & d\end{Vmatrix}, \begin{smallmatrix} a & b \\ c & d\end{smallmatrix}.\)

Cases

f(n) = \begin{cases} n/2 &\mbox{if } n \equiv 0 \\ 
(3n +1)/2 & \mbox{if } n \equiv 1. \end{cases} \pmod{2}

\( f(n) = \begin{cases} n/2 &\mbox{if } n \equiv 0 \\ (3n +1)/2 & \mbox{if } n \equiv 1. \end{cases} \pmod{2}\)

Braces

z = \overbrace{\underbrace{x}_\text{real} + \underbrace{iy}_\text{imaginary}}^\text{complex number}

\(z = \overbrace{ \underbrace{x}_\text{real} + \underbrace{iy}_\text{imaginary} }^\text{complex number}\)

w^1_1=
\overbrace{\phantom{(\beta\gamma)\beta(\alpha\beta)}}^{c_1}
(\beta\gamma)\beta
\underbrace{\phantom{(\alpha\beta) (\alpha\beta)}}_{c_2}
(\alpha\beta)
\overbrace{\phantom{(\alpha\beta)\alpha\beta^{-1}}}^{c_3}
(\alpha\beta) \alpha
\underbrace{\phantom{(\gamma\alpha)(\gamma\alpha)}}_{c_4}
(\gamma\alpha)
\overbrace{\phantom{(\gamma\alpha) \gamma(\beta\gamma)}}^{c_5}
(\gamma\alpha) \gamma(\beta\gamma)

Braces.png

xy-matrix

Arrow placing example:

\[\xymatrixcolsep{3pc}\xymatrix{
 G(\Gamma) \ar[r]^<<<<<<<{\prod_i \phi_{g_i}} &  \prod_{i=1} G_i\ar[r] & G. }\]

Packages

MathTools

Ceiling/form

\usepackage{mathtools}
\DeclarePairedDelimiter{\ceil}{\lceil}{\rceil}
\DeclarePairedDelimiter{\form}{\langle}{\rangle}
\ceil{x}, \form{x}
\ceil*{x}, \ceil[\big]{x}, \ceil[\Big]{x}, \ceil[\bigg]{x}, \ceil[\Bigg]{x},

\(\lceil x\rceil, \langle x \rangle\)

where \ceil*,\form* puts \left and \right.

TikZ

plot a curvy cycle

\draw [red,dashed] plot [smooth cycle]% 
coordinates  {($ (v) + (1,1) $) (2,2) (3,5) (0,0)};

node on the middle

\draw [DarkOrchid,out=20,in=160]  (0,0) edge node[pos=.45,v,black] (m) {} node [pos=.45,below] {\tiny $P$} (1,2);

Example

Thin and slim triangles

\begin{figure}
  \tikzstyle {v}=[draw,shape=circle,fill=black,inner sep=.5pt]
  \tikzstyle{every edge}=[-,draw]
\subfloat[(a)]{\begin{tikzpicture}[thick,scale=.7]
	\foreach \i in {0,1,2} {
		\draw (360/3*\i+90:2) node [v] (w\i) {} ;
		}
\draw (.5,-.1) node [below,DarkOrchid] {\tiny $\alpha$};
\draw (-.7,.5) node [below,red] {\tiny $\gamma$};
\draw (.8,.5) node [below,blue] {\tiny $\beta$};
\draw (2,.2) node [below,blue] {\tiny $N_\delta(\beta)$};
\draw (-2,.2) node [below,red] {\tiny $N_\delta(\gamma)$};
\draw [DarkOrchid,out=60,in=120] (w1) edge  
		(w2);
\draw [blue,out=30+120,in=150+120] (w2) edge  
		 (w0);					
\draw [red,out=30-120,in=150-120] (w0) edge  
		(w1);				
\draw [red,dashed] plot [smooth cycle] coordinates 
{($ (w1) + (-.5,-.4) $) ($ (-1,.3) $)($(w0)+(.2,.6)$) ($ (.3,0) $)};
\draw [blue,dashed] plot [smooth cycle] coordinates 
{($ (w2) + (.5,-.4) $) ($ (1,.3) $)($(w0)+(-.2,.6)$) ($ (-.3,0) $)};
\end{tikzpicture}}
$\qquad$
\subfloat[(b)]{\begin{tikzpicture}[thick,scale=.9]
\draw (120*0 + 90:2)+(.2,0) node [v] (w0) {} node [above] {\tiny $A$};
\draw (120*1 + 90:2) node [v] (w1) {}  node [left] {\tiny $B$};
\draw (120*2 + 90:2) node [v] (w2) {} node [right] {\tiny $C$};
\draw [DarkOrchid,out=20,in=160] (w1) edge  
		node[pos=.45,v,black] (m) {}
		node [pos=.45,below] {\tiny $P$} 		 
		(w2);
\draw [blue,out=20+120,in=150+120] ($(w2)$) edge  
		 (w0);					
\draw [red,out=20-120,in=150-120] (w0) edge  
		(w1);		
\draw [dashed,PineGreen] (w0) edge (m);	
\end{tikzpicture}}
\end{figure}

F-thin-triangle.png

Surface with separating curves

\begin{tikzpicture}[scale=.7]
\draw (1,-2) -- (12,-2);
\draw (1,2) edge [out=180,in=180] (1,-2) edge (12,2);
\draw (2,.5) edge [out=0,in=90]  (2.5,0) edge [out=180,in=90] (1.5,0) ;
\draw (2,-.2) edge [out=0,in=-135]  (2.6,.1) edge [out=180,in=-45] (1.4,.1);
\draw (6,.5) edge [out=0,in=90] (6.5,0) edge [out=180,in=90] (5.5,0);
\draw (6,-.2) edge [out=0,in=-135] (6.6,.1) edge [out=180,in=-45] (5.4,.1);
\draw (10,.5) edge [out=0,in=90] (10.5,0) edge [out=180,in=90] (9.5,0);
\draw (10,-.2) edge [out=0,in=-135] (10.6,.1) edge [out=180,in=-45] (9.4,.1);
\draw (6,1.5)  edge  [out=180, in=30] (2.27,.41)  edge [out=0, in=90]  (7.5,0);
\draw (6,-1.5) edge [out=180, in=-30] (2.27,-.16) edge [out=0, in=-90] (7.5,0);
\draw (6,.95) edge [dashed, out=180, in=10] (2.27,.41);
\draw [dashed, out=-10, in=180] (2.27,-.16) edge (6,-.95);
\draw (7,0) edge [dashed,out=90, in=0] (6,.95) edge [dashed,out=-90, in=0] (6,-.95);
\draw (9.73,.41) edge [out=150, in=0] (6,1.2) edge  [dashed, out=170, in=0] (6,.75);
\draw  (9.73,-.16) edge  [out=-150, in=0] (6,-1.2) edge [dashed, out=-170, in=0] (6,-.5);
\draw (4.5,0) edge  [out=-90, in=180] (6,-1.2) edge  [out=90, in=180] (6,1.2);
\draw (5,0) edge [dashed,out=90, in=180] (6,.75) edge [dashed,out=-90, in=180] (6,-.5);
\draw  (3.5,2) edge [out=-75,in=75] (3.5,-2) edge [dashed,out=-105,in=105](3.5,-2);
\draw  (8.5,2) edge [out=-75,in=75] (8.5,-2) edge [dashed,out=-105,in=105]  (8.5,-2);
\end{tikzpicture}
Torelli-g3.png

Lyx

A reliable WYSIWYG front-end for TeX. (I do not use this since I personally prefer non-WYSIWYG.)

Converter Install (Mac)

If you see "Error converting to loadable format" error while displaying PDF graphics, try the following.

  1. Click MacPorts and install it:
  2. Run Terminal at:
    Applications > Utilities > Terminal
  3. In the Terminal window, type
    sudo port install ImageMagick
    You might need to type in your password. Takes < 10 minutes.
  4. On the menu bar, go to
    Lyx > Preferences > File Handling > Converters
    and choose "EPS -> PDF". Make sure the "To format" is set as PNG (not PDF). In the "Converter:" box, type
    convert $$i $$o
    Apply and Save.
  5. In the menu
    Preferences > Paths > Path prefix
    add at the end of the paths
    :/opt/ImageMagick/bin
  6. Exit and re-run Lyx. Try the pictures now.