Sunteți pe pagina 1din 3

A L TEX TIPS

JAMES HOLBERT JMHOLBER@NCSU.EDU

N.B. I prefer using \documentclass{amsart} because it automatically includes A most of the enhancements provided by the AMS version of L TEX. Hence, if you are using \documentclass{article} and something does not work as I describe below, then the problem may be caused by not using the amsart document class. 1. Nonmath Stuff
A 1.1. Sections, subsections, etc. Let L TEX handle your section headings and spacing. The sectioning commands available in the article or amsart document classes are \section, \subsection, \subsubsection, \paragraph, \subparagraph. For example, we are in a subsection right now, and the code beginning this subsubA section is \subsection{Sections, subsections, etc}. L TEX will automatically number the sections. A To tell L TEX to not number the section, use the starred version of the command, e.g., \subsection*{An Unnumbered Section Here}. This may be helpful if you are typing up homework and want to use the problem number as the heading, e.g., \subsection*{p. 118, \# 3}.

1.2. Title, author, date. The following code snippet should make this clear: \documentclass{article} \title{Tractatus Logico-Philosophicus} \author{Ludwig Wittgenstein} \date{WW I} \begin{document} \maketitle \end{document}
A 1.3. Commenting. Use the % character to tell L TEX to ignore everything after the % on that line. This is handy when debugging, or for documentation. For example, we might have this in our source le M(x,y) \, dx \wedge dy % the \, adds a thinspace Use the comment package to comment out a whole block of text by just enclosing it in a comment environment. For example, \subsection*{Extra Credit} Find all compositions of 100 with distinct parts. \begin{comment} \subsection*{Solution}

Date: Fall 2008.


1

Ill uncomment this block when I want to show the solution. \end{comment} To use the comment package, just make sure you have \usepackage{comment} in the preamble, i.e., somewhere between \documentclass{article} and \begin{document}.

1.4. Your own commands. Use \newcommand and \renewcommand to dene your own time-saving commands. For example, to make it easier to code f , use this x code in your preamble \newcommand{\pfx}{\frac{\partial f}{\partial x}}. Then you can just type $\pfx$ to get f . x You can have variables with your commands too. For example, \newcommand{\pd}[2]{\frac{\partial{#1}}{\partial{#2}}}
g will allow you type $\pd{f}{x}=\pd{g}{y}$ to get f = y . The [2] just says x how many arguments your command has. And {#1} and {#2} are just where your arguments will be substituted. renewcommand just lets you redene a command that is already dened. That is, if you use newcommand and the name of your command is already in use for A A something else, L TEX will complain. To force L TEX to use your new denition, use renewcommand instead of newcommand. This is more powerful than just allowing you to use a name you really like. For example, there are two typeset versions of the Greek letter phi, and with commands \phi and \varphpi, respectively. If you prefer the style and want to type $\phi$ instead of $\varphi$, then use \renewcommand{\phi}{\varphi}.

1.5. Page numbering, headers, footers. If your document is just one page, A L TEX will usually put a page number at the bottom of the page. Use \thispagestyle{empty} to suppress the page number. N.B. this needs to be after the \begin{document} A statement; otherwise L TEX cant gure out what page thispage is. You can also use one of \pagestyle{empty} \pagestyle{plain} \pagestyle{headings} to get dierent headers and footers on your pages. Put one of these in the preamble to see what it does.

A 1.6. Quotation marks. There is a special way to make L TEX do quotation marks correctly, i.e., I typed special to get special. Contrast this with special which results from "special". 2

2. Math Stuff 2.1. Matrices. An easy way to get a matrix is to use one of the matrix environments. We have matrix, bmatrix, pmatrix, and vmatrix. For example, 0 Ez Ey 0 Ez Ey Ez Ez 0 Ex , 0 Ex , Ey Ex 0 Ey Ex 0 0 Ez Ey 0 Ez Ey Ez Ez 0 Ex 0 Ex , and Ey Ex 0 Ey Ex 0 were all typeset with \begin{matrix} 0 & E_z & -E_y \\ -E_z & 0 & E_x \\ E_y & -E_x & 0 \end{matrix} or the corresponding bmatrix, pmatrix, vmatrix versions. To get a small matrix that looks good with inline text, we can use smallmatrix, e.g., $(\begin{smallmatrix}1&0\\0&1\end{smallmatrix})$ yields ( 1 0 ). 01 2.2. Spacing. Sometimes a thinspace (\,) makes things look better, e.g., exy dx dy looks better than exy dxdy \iint e^{xy} dx dy \iint e^{xy} \, dx \, dy

S-ar putea să vă placă și