LaTeX

From Christoph's Personal Wiki
Revision as of 01:16, 24 June 2008 by Christoph (Talk | contribs) (Tutorials/FAQs)

Jump to: navigation, search

LATEX, written as LaTeX in plain text, is a document preparation system for the TeX typesetting program.

Examples

Document (basics)

Article with text only

\documentclass{article}

\begin{document}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis dapibus. 
In hac habitasse platea dictumst. Aenean eu velit. Nullam eros. Vestibulum 
scelerisque tristique nisl. Maecenas in tortor sit amet justo rhoncus 
blandit. Cras eget ipsum bibendum massa ultricies sodales. Ut est arcu, 
elementum et, sagittis eget, pellentesque at, sem. Nam tincidunt. Curabitur 
urna arcu, ultrices nec, blandit ullamcorper, hendrerit id, ante. In 
tincidunt nonummy orci. Quisque eget sem. Ut aliquam augue eu libero. Sed 
turpis dui, euismod vel, ultricies sed, porta eget, lacus.
\end{document}

Definition of macros for later use in document

\documentclass{article}
\usepackage{german}

% The example macro generates the marker for an example inside a document
\def\example{\refstepcounter{subsection}
	\paragraph{\underline{$\rhd$\ Example\ \thesubsection}}}

\begin{document}

To generate the header for an example inside your document you now
	simply need to type:

\example

\end{document}

Inserting Graphics

The easiest way inserting graphics into your document is using the graphicx graphic bundle. Afterwards PostScript (ps) and Encapsulated PostScript Images (eps) can be inserted by saying \includegraphics.

\begin[a4paper]{article}
\usepackage{graphicx}

\begin{document}

\begin{figure}[h]
	\centering
	\includegraphics[width=5cm]{box.ps}
	\caption{This is an example for including a graphic using
	\texttt{graphicx.sty} and the \texttt{figure} environment}
	\label{fig:box}
\end{figure}

\end{document}

Extended

\documentclass[amsmath,amssymb]{revtex4}
\usepackage{graphicx}% Include figure files
\usepackage{dcolumn}% Align table columns on decimal point
\usepackage{bm}% bold math
\usepackage{epsfig}% include .eps files for figures
\usepackage[frenchb]{babel}% SmallCaps font

\begin{document}
...
\end{document}

Tables

\begin{table}
\caption{\label{tab:table1}Table Title}
\begin{ruledtabular}
\begin{tabular}{rrrrrrrrrr}
\multicolumn{5}{c}{Heading 1}&\multicolumn{5}{c}{Heading 2}\\
Seg & Res & Atom & $<B>$ & $<$A$>$ & RMSD & {$T^rB$} & eval & $<B>$ & $<$A$>$\\
\hline
1-9 & 9 & 63 & 22.2 & 1.00 & 10.34 & 8.6 & 146.39 & 22.2 & 0.30\\
10-15 & 6 & 41 & 14.7 & 1.00 & 6.99 & 1.3 & 0.00 & 14.7 & 0.17\\
16-29 & 14 & 119 & 12.7 & 1.00 & 6.12 & 2.0 & 73.85 & 12.7 & 0.32\\
30-47 & 18 & 130 & 7.4 & 1.00 & 2.79 & 2.9 & 11.28 & 7.4 & 0.69\\
48-56 & 9 & 66 & 14.4 & 1.00 & 4.77 & -0.5 & 58.11 & 14.4 & 0.32\\
\end{tabular}
\end{ruledtabular}
\end{table}

Figures

Adding figures is easy in LaTeX:

ps2epsi input.ps output.eps
\usepackage{epsfig} % place at top of .tex file
...
\begin{figure}[hbt]
\begin{center}
\psfig{file=output.eps,width=3.25in}
\end{center}
\caption[short TOC caption]{\em Testing 1FIN.}
\label{ReferenceLabelHere}
\end{figure}

Watermarks

\documentclass{article}
\usepackage{graphicx}
\usepackage{type1cm}
\usepackage{eso-pic}
\usepackage{color}
\makeatletter
\AddToShipoutPicture{%
            \setlength{\@tempdimb}{.5\paperwidth}%
            \setlength{\@tempdimc}{.5\paperheight}%
            \setlength{\unitlength}{1pt}%
            \put(\strip@pt\@tempdimb,\strip@pt\@tempdimc){%
        \makebox(0,0){\rotatebox{45}{\textcolor[gray]{0.75}%
        {\fontsize{6cm}{6cm}\selectfont{DRAFT}}}}%
            }%
}
\makeatother
\title{Lorem ipsum}
\begin{document}
\maketitle
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis dapibus. 
In hac habitasse platea dictumst. Aenean eu velit. Nullam eros. Vestibulum 
scelerisque tristique nisl. Maecenas in tortor sit amet justo rhoncus 
blandit. Cras eget ipsum bibendum massa ultricies sodales. Ut est arcu, 
elementum et, sagittis eget, pellentesque at, sem. Nam tincidunt. Curabitur 
urna arcu, ultrices nec, blandit ullamcorper, hendrerit id, ante. In 
tincidunt nonummy orci. Quisque eget sem. Ut aliquam augue eu libero. Sed 
turpis dui, euismod vel, ultricies sed, porta eget, lacus.
\end{document}

tex2ps

Convert your TeX file to a PostScript file ready for printing:

latex input.tex && dvips -f input.dvi > output.ps

Or, as a shell script:

latex $1.tex && dvips -f $1.dvi > $1.ps

HTML to LaTeX

see: http://html2latex.sourceforge.net/
%html -d tag-name options "LaTeX-open" "LaTeX-close"
%html -d html    ""  ""
%html -d head    ""  ""
%html -d title   ""  ""
%html -d body    -on ""  ""
%html -d address ""  ""
%html -d h1      -l1 "{\\LARGE \\bf " "}"
%html -d h2      -l2 "{\\Large \\bf " "}"
%html -d h3      -l3 "{\\large \\bf " "}"
%html -d h4      -l4 "{\bf " "}"
%html -d h5      -l5 "{\\small \\bf " "}"
%html -d h6      -l6 "{\\footnotesize \\bf " "}"
%html -d p       "\nl\nl"  ""
%html -d ul      -igh "\nl\begin{itemize}"  "\nl\end{itemize}\nl"
%html -d menu    -igh "\nl\begin{itemize}"  "\nl\end{itemize}\nl"
%html -d dir     -gnh "\nl\begin{itemize}"  "\nl\end{itemize}\nl"
%html -d ol      -igh "\nl\begin{enumerate}"  "\nl\end{enumerate}\nl"
%html -d li      "\nl\item "  ""
%html -d lh      "\nl\item "  ""
%html -d dl      -igh "\nl\begin{description}"  "\nl\end{description}\nl"
%html -d dt      "\nl\item["  "]"
%html -d dd      ""  ""
%html -d a       ""  ""
%html -d q       "``"  "''"
%html -d i       -iim "{\em "  "}"
%html -d em      "{\em "  "}"
%html -d b       "{\bf "  "}"
%html -d strong  "{\bf "  "}"
%html -d tt      "{\tt "  "}"
%html -d samp    "{\tt "  "}"
%html -d kbd     "{\tt "  "}"
%html -d var     "{\sl "  "}"
%html -d dfn     "{\sc "  "}"
%html -d code    "{\tt "  "}"
%html -d blink   ""  ""
%html -d cite    "{\em "  "}"
%html -d blockquote  -igh "\begin{quotation} "  "\end{quotation}\nl"
%html -d bq      -igh "\begin{quotation} "  "\end{quotation}\nl"
%html -d u       "\underbar{"  "}"

%html -d pre     -verb "\begin{verbatim} "  "\end{verbatim}\nl"
%html -d xmp     -verb "\begin{verbatim} "  "\end{verbatim}\nl"
%html -d listing -verb "\begin{verbatim} "  "\end{verbatim}\nl"
%html -d br      -br "\newline\nl"  ""
%html -d hr      "\vspace{1mm}\hrule "  ""
%html -d img     ""  ""
%html -d isindex ""  ""
%html -d select  ""  ""
%html -d link    ""  ""
%html -d center  "{\centering "  "}"
%html -d meta    ""  ""
%html -d table   ""  ""
%html -d tr      ""  ""
%html -d td      ""  ""
%html -d sup     "$^{" "}$"
%html -d sub     "$_{" "}$"
  • Suggested alternative settings for the various tags are:
%html -d title -on "\newpage\thispagestyle{myheadings}\markright{\sc{}" "}\pagenumbering{arabic}\nl\nl"
%html -d h1 -l1 "{\nl\nl\smallskip\LARGE\bf\noindent " "}\nl\nl\noindent{}"
%html -d h2 -l2 "{\nl\nl\smallskip\Large\bf\noindent " "}\nl\nl\noindent{}"
%html -d h3 -l3 "{\nl\nl\smallskip\large\bf\noindent " "}\nl\nl\noindent{}"
%html -d h4 -l4 "{\nl\nl\smallskip\bf\noindent " "}\nl\nl\noindent{}"
%html -d h5 -l5 "{\nl\nl\smallskip\small\bf\noindent " "}\nl\nl\noindent{}"
%html -d h6 -l6 "{\nl\nl\smallskip\footnotesize\bf\noindent " "}\nl\nl\noindent{}"
%html -d code -math
%html -d blockquote "\nl{\parindent=2em\narrower\nl" "\nl}\nl"
  • The default setting for the pseudo tags for the book and report styles are:
%html -d l1      "\nl\nl\chapter{"  "}\nl\nl"
%html -d l2      "\nl\nl\section{"  "}\nl\nl"
%html -d l3      "\nl\nl\subsection{"  "}\nl\nl"
%html -d l4      "\nl\nl\subsubsection{"  "}\nl\nl"
%html -d l5      "\nl\nl\paragraph{"  "}\nl"
%html -d l6      "\nl\nl\subparagraph{"  "}\nl"
%html -d l7      ""  ""
%html -d l8      ""  ""
%html -d l9      ""  ""
  • The default setting for the pseudo tags for the article styles is:
%html -d l1      "\nl\nl\section{"  "}\nl\nl"
%html -d l2      "\nl\nl\subsection{"  "}\nl\nl"
%html -d l3      "\nl\nl\subsubsection{"  "}\nl\nl"
%html -d l4      "\nl\nl\paragraph{"  "}\nl"
%html -d l5      "\nl\nl\subparagraph{"  "}\nl"
%html -d l6      ""  ""
%html -d l7      ""  ""
%html -d l8      ""  ""
%html -d l9      ""  ""
  • The default setting for the pseudo tags for the plain style is:
%html -d l1      "\nl\nl\section*{"  "}\nl\nl"
%html -d l2      "\nl\nl\subsection*{"  "}\nl\nl"
%html -d l3      "\nl\nl\subsubsection*{"  "}\nl\nl"
%html -d l4      "\nl\nl\paragraph*{"  "}\nl"
%html -d l5      "\nl\nl\subparagraph*{"  "}\nl"
%html -d l6      ""  ""
%html -d l7      ""  ""
%html -d l8      ""  ""
%html -d l9      ""  ""

External links

Community

  • Official LaTeX project site web site for open development of LaTeX (you can also obtain a CVS snapshot of LaTeX3, the next version of LaTeX which is not yet released)
  • CTAN.org — the Comprehensive TeX Archive Network
  • The TeX Users Group
  • comp.text.tex. A Usenet newsgroup for (La)TeX related questions, comp.text.tex is an invaluable resource for (La)TeX. Search the archives with Google Groups before posting.
  • #latex IRC chat room on Freenode

Periodicals

Tutorials/FAQs

Add-on Packages

Utilities

Reference

Other