20 August 2004 These notes are latex tips and tricks that I have found useful or thought might be useful. I wrote these for my own use and have not tried to make them clear for others, but some other people will find them useful. --Eric Rasmusen, erasmuse@indiana.edu http://rasmusen.org http://rasmusen.org/x/images/latex-rasmusen.txt ------------------------------------------------------------------------ RAGGEDRIGHT, LEFT JUSTIFICATION The tex default is to right- and left-justify the page, which looks very professional. I just read, though, that psychologists find this actually slows down reading compared to just left-justifying, because people are not used to the diverse spacing of letters and words that is required for uniform margins on both sides. Also, a raggedright looks better for working papers, I think. The command for that is \begin{raggedright} \parindent 24pt \parskip 10pt \end{raggedright} You need to put the parident and parskip commands AFTER the begin{raggedright} ------------------------------------------------------------------------ PROCESSING TEX The free Miktex (http://www.miktex.org/) looks to be an excellent latex and tex Windows processor program. I've been using SWP, and putting figures in looks to work better in Miktex. Miktex gets PDF's right, which my version of SWP does not always do, and it processes straight from myfile.tex to myfile.pdf. On the other hand, it has some problems, noted below, which make it unhandier to use. (1) I have a suggestion for the standard installation instructions: say more about the Windows command prompt. I haven't used it for years, though I happened to remember it was in Accessories. Also, the user should know that he can change the default directory in teh command prompt to wherever he keeps his tex input files-- say, d:/smith/latex-input, using the Properties (reachable by right clicking the command prompt). (2) The command prompt requires you to type in all your commands, which is burdensome if they are long, e.g., pdflatex D:\_home\_HomeWD\INCOMING\FIGURECOPY/myfilewithalongname.tex You can't copy and paste in the usual way with CTRL-C and CTRL-V. What you can do, though is to copy to the clipboard with CTRL-C and then paste by rightclicking on the Command Prompt program and choosing PASTE. I will put a comment line like this at the start of my tex files: % pdflatex -job-name=chap07_MoralHazard temp.tex then I can copy all but the % part and paste it into the command prompt, and it will process temp.tex and write to chap07_MoralHazard.pdf (3) Something better would be a graphic interface to replace the command prompt. I don't know how to write such an interface, but here is what it would be: It would be simple: just a window in which the user could do two things: 1. Browse and choose a tex file to process, e.g., myfilewithalongname.tex, instead of having to type in the full name in the command prompt, and instead of having to have it in the command prompt's directory. 2. Issue the processing command--- most simply "latex myfilewithalongname.tex", or "pdflatex", or others that might be useful. There should be two to five choices, and the user would check the box of the command he wants to use. The command would take the file from (1) and put the output in the same directory as the input. The interface could be fancier, but that covers what the user needs every single time he uses Miktex, and it would save a lot of tricky typing. (4) Miktex is fouled up by carriage returns, even ones that are not hard breaks. Thus, before I tex my files using it I need to strip off all the carriage returns, thus making all my equations, nicely separated into separate lines for visibility, into unreadable paragraphs. I will do that just before I tex each file, I guess. I will save chap07_MoralHazard.tex as temp.tex and strip off all the carriage returns, save it again and process it. That is a serious defect. For example: \begin{equation} \label{e7.1} U(e, w(e)) = \overline{U}. \end{equation} must become: \begin{equation} \label{e7.1} U(e, w(e)) = \overline{U}. \end{equation} (5) The command which takes us straight from myfile.tex to the output myfile.pdf produces pdf files which are not crystal clear on the screen. The commands (6) Miktex does not recognize the \tag{\ref{e7.6}} command. Instead, to do a cross-reference, use $$ f(x) =x)\;\;\;\;\;\;\;\;\;\;\;\;\;\;(\ref{e7.6}) $$ latex -job-name=chap07_MoralHazard temp.tex dvips -Ppdf chap07_MoralHazard.dvi do better, but then I can't use JPG files in my input. (7) Will I switch from SWP to Miktex? Money is not really a concern for me, but usability is. I'll try it for a while and see. ------------------------------------------------------------------------ http://www.usq.edu.au/users/leis/notes/latex/ has good latex diagram instructions. use pdflatex temp.tex, and include in temp.tex these two lines: \usepackage{graphicx}% goes at the start \includegraphics[width=100mm]{3dplot.jpg}% where I wnat the pdf or jpg figure. ------------------------------------------------------------------------ \begin{raggedright} ... sadfasfdsadf \end{raggedright} ------------------------------------------------------------------------ Diagrams: use alt-PRINT SCREEN to do a screen capture and use PAINT to mak a JPG. ------------------------------------------------------------------------ \widetilde{12345} ------------------------------------------------------------------------ Some people prefer to represent vectors in bold-face rather than using a little arrow over the symbol. It's not so clear what you're talking about, but it looks nicer. We're all in Math, and since when did clarity mean anything? LaTeX completely ignores the \bf in stuff like ${\bf \xi}$, but has \boldmath to get around this. Unfortunately, it only works in text-mode, not math-mode. But (yet another 'but') you can get around this, too, with a little trick or two. Thanks, Michèle, for the code: % newcommands to make things easier to use later: \newcommand{\xv}{\mbox{\boldmath$x$}} \newcommand{\uv}{\mbox{\boldmath$u$}} \newcommand{\xiv}{\mbox{\boldmath$\xi$}} ... The vector $\xiv$ represents the location of the centre of the body, and clearly \[ \uv \sim -\log(\xv - \xiv)\ . \] Notice you still surround the math with $...$ in the text, but don't need them when you're in math-mode. ------------------------------------------------------------------------ To change size of any operator like { | } [ ] ( ), one need to use commands \big \Big \bigg \Bigg For example, \bigg| These command are in order of increasing size. This is especially good for |, since it can take superscripts and subscripts properly then, unlike with \left| ------------------------------------------------------------------------ \begin{eqnarray} F(x) &= &3x^2\\ & & \nonumber \\ & =& 4z \end{eqnarray} Use \begin{eqnarray}* to not have any nubmers. Note that there are always 3 columns. ------------------------------------------------------------------------ \pagestyle{myheadings} \markboth { Ramseyer-Rasmusen }{ Ramseyer-Rasmusen} ------------------------------------------------------------------------ \documentclass[12pt,epsf,leqno, fleqn]{article} This is for left equation numbering, and for not centering the equations but rather putting them towards the left at a fixed indent from the margin. \documentclass is always better than \documentstyle, because it permits packages to be used. Also, this does 12 pt type. ------------------------------------------------------------------------ THE LARGE CURLY BRACKET: \left\{ For integrals, to get them in the large style in Arrays or in text: \begin{array}{ll} \pi_1^d & ={\displaystyle -c + \int_0^{Eu} \left( \int_v^z (u- v) f(u) du \right) g(v) + \int_{Eu}^v \left( \int_v^z( u-v) f(u) du \right) g(v)dv. }\\ & \\ &= -c + A_1 + A_2. \\ \end{array} ------------------------------------------------------------------------ Use $\Beta$ in tex, rather than $B$, so I can globally change it easily later. ------------------------------------------------------------------------ PROOF END SYMBOL At the start, have: \usepackage{graphicx} \usepackage{amsmath} \usepackage{amssymb} Then put $\blacksquare$ at the end of the proof. ------------------------------------------------------------------------ double spacing \baselineskip 24pt This goes AFTER Begin Document. ------------------------------------------------------------------------ \pagestyle{empty} This last command will remove page numbers. (put before the Begin Document) ------------------------------------------------------------------------ \topmargin -1.5in ------------------------------------------------------------------------ Type sizes: Huge huge LARGE Large large normalsize small footnotesize scriptsize tiny ------------------------------------------------------------------------ DIFFERENT FONTS: But these do not reliably work. \begin{ttfamily} text goes here. \end{ttfamily} \begin{sffamily} text goes here. \end{sffamily} \textsf \sffamily Sans serif family \texttt \ttfamily Typewriter family ------------------------------------------------------------------------ http://www.mackichan.com/ Here is how to make a tex DVI file into a postscripgt file: dvips 9.dvi -Z -o myfile.ps The -Z compresses it. The postcript files are quite large, though. (394K from 70 K, for example, with 3 diagrams). The -Z commadn will comrpess it about 40 prcent, I think, and it will still pirint drictly. TO TURN A DVI FILE INTO AN ASCII FILE: uuencode 9.dvi 9.dvi> negot.asc ------------------------------------------------------------------------ UNDERSCORE, UNDERLINE \_ is ok, no math $$ needed. ------------------------------------------------------------------------ Question: I find that LaTeX leaves too much space in the left and top margins of the table; is it possible to center the table in the physical page? Answer:Yes, make your table like: \centerline { \begin{table} \begin{tabular}{||c|c||} entry 1 & entry 2 \\ entry 3 & entry 4 \end{tabular} \end{table} } ------------------------------------------------------------------------ FOOTNOTES WITH SYMBOLS. This will make the first footnote an asterisk and the second one a dagger,and then goes back to the default, nubmers, starting with number 1. \renewcommand{\thefootnote}{\fnsymbol{footnote}} Here's is one\footnote{starred note} and here is a second.\footnote{Daggered footnote} \renewcommand{\thefootnote} \setcounter{footnote}{0} FOOTNOTES. To do asterisk footnotes, use the command: Here is the text$^*$\footnotetext{$^*$ Here is the footnote}. ------------------------------------------------------------------------ FOR OVERHEADS AND HANDOUTS: \reversemarginpar \topmargin -1in \oddsidemargin -.25in \textheight 8.7in \textwidth 7in \pagestyle{empty} ------------------------------------------------------------------------ \pagenumbering{roman} This also restarts the numbering to 1. ------------------------------------------------------------------------ \pagestyle{myheadings} \markboth { } {$\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\; \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\; \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\; \;\;\;\;\;\;$ Lyon and Rasmusen } % these two things in conjunction put the page nubmers at the upper % right of each page, with "Lyon and Rasmusen" just before them. ------------------------------------------------------------------------ LISTS \listoffigures \listoftables ------------------------------------------------------------------------ \begin{comment}% I need to have \usepackage{verbatim} This is a comment. \end{comment} ------------------------------------------------------------------------ \begin{verse} This is the first line of a poem\\ Here is the second, hwich is so long that it runs over on to the next line, where it will be indented.\\ And here is the third.\\ \end{verse} ------------------------------------------------------------------------ $$ {Maximize \atop x } x^2-x $$ $$ {Maximize \atop \scriptstyle{x} } x^2-x %Tthe scritpstyle is too small, really. $$ ------------------------------------------------------------------------ The table is on page \pageref{t1}. %This prints the page number where label t1 is found. ------------------------------------------------------------------------ {\it Here is some italics but with \emph{these words} emphasized in Roman.} I can also use the same command to get \emph{italics} in the middle of Roman words. ------------------------------------------------------------------------ \begin{description} \item[Oranges:] a fruit that Amelia likes a lot, just as she likes grapes and pickles. \item[Lettuce:] something Amelia does not like. \end{description} ------------------------------------------------------------------------ The command @{} kills the space between columns in a table and replaces it with whatever is in curly brackets. It can be used to cleverly align tables around decimal points, thus: \begin{table} [! h] %This puts the table right here, not floating. \begin{table}[! h t] %This puts the table here or top \begin{figure}[! b f] %This puts it at the bottom or on a float page. \begin{table}[!b] \label{t1} \begin{tabular} {l r @{.} l} Variable & Mean\\ X & 1 & 234\\ Y & 23 & 1\\ Z & 1456 & 34567\\ \end{tabular} ------------------------------------------------------------------------ \caption{The World in 1812} %This will appear as Table 1: The World... \end{table} ------------------------------------------------------------------------ \dotfill for a long line of dots. ------------------------------------------------------------------------ I need to write large tables that span many pages; I tried the tabular environment but found out that it put everything on one page, with most of the text going down the drain, i.e. below the physical page. Is there a way of doing this smoothly, that is, without breaking the large table into smaller ones that would approximately fit into one page each? Answer: For LaTeX2e: You should look into either supertab.sty or longtable.sty, both can be found in: /usr/um/generic/tex3.141/latex2e/tools/ with documentation in: /usr/um/generic/tex3.141/latex2e/tools/doc/ in the form of .dtx and .dvi files, you can run LaTeX on the .dtx files, or simply look at the .dvi files. ------------------------------------------------------------------------ ENDNOTES: Usepackage{endnotes} \endnote{Here it is.} At the endo f the document, put \theendnotes to have them print out. ------------------------------------------------------------------------ \not\exists for an exists symbol with a slash through it. ------------------------------------------------------------------------ %\reversemarginpar % \topmargin -.4in % \oddsidemargin .25in % \pagestyle{myheadings} % \markboth{Rasmusen } { } \begin{document} \baselineskip 16pt % 16 pt line spacing is the best for easy reading. ------------------------------------------------------------------------ PACKAGES To put in a package: All packages are located in TCItex/tex/latex . I am not sure if I can put a new one in with a new directory, and it will get read in. Tha owrked at the office, but not at home, f or a0poster. I can just use ADD to get verbatim. A0poster is good for large font sizes. \documentclass[article ]{a0poster} \usepackage{a0size} ------------------------------------------------------------------------ HELP INDEX doesn't work in SWP. ------------------------------------------------------------------------ GRAPHICS: SWP gave me a lot of trouble over graphics using EPS. The way it finally worked was that I converted the file suffix from *.eps to *.ps, installed a patch 30filtup.exe from the SWP people, http: //www.mackichan.com/techtalk/v30/selectingpsgfxfilter.htm, and used the command: \usepackage{graphicx}%This goes before Begin{document} {\includegraphics[height=2.8193in,width=6.7853in] {Bertrand2.ps}} The easier thing is just to use JPG's. If I want to put JPG's into chap01.tex, do the following. Create a new file in SWP. Use FILE-INSERT PICTURE to put in the desired JPG. Save the file to temp.tex. Then copy from temp.tex to chap01.tex. Then replace the command \FRAME{dtbpF} with \FRAME{itbpFU}, so there is no caption and so the picture goes where it is put, rather than floating where latex wnats to put it. Below seems to work for not having any caption:\FRAME{itbpFU} is crucial: \FRAME{itbpFU}{3.4212in}{2.405in}{0pt}{\Qcb{ }}{}{a1.jpg} {\special{language "Scientific Word";type "GRAPHIC";maintain-aspect- ratio TRUE; display "USEDEF";valid_file "F";width 3.4212in;height 2.405in;depth 0pt;original-width 3.3754in;original-height 2.3644in; cropleft "0"; croptop "1";cropright "1";cropbottom "0";filename '_Figures_Answers/New.JPG.figures/A1.jpg';file-properties "XNPEU";}} Or, to add a caption: \FRAME{itbpFU}{3.4212in}{2.405in}{0pt}{\Qcb{Figure 2a: The Normal Distribution }}{}{a1.jpg} {\special{language "Scientific Word";type "GRAPHIC";maintain-aspect-ratio TRUE; display "USEDEF";valid_file "F"; width 3.4212in;height 2.405in;depth 0pt;original-width 3.3754in; original-height 2.3644in; cropleft "0"; croptop "1";cropright "1"; cropbottom "0";filename '_Figures_Answers/New.JPG.figures/A1.jpg';file- properties "XNPEU";}} ------------------------------------------------------------------------ In TEXTPAD, hard breaks are put in, sometimes in awkward places, so I may have to do some fiddling to make sure key commands do not get cut across lines. ------------------------------------------------------------------------ The easiest way to get headings of funny 'sections' such as prefaces in the table of contents is to use the counter secnumdepth described in Appendix C of the LaTeX manual. For example: \setcounter{secnumdepth}{-1} \chapter{Preface} Of course, you have to set secnumdepth back to its usual value (which is 2 in the standard styles) before you do any 'section' which you want to be numbered. Similar settings are made automatically in the LaTeX book class by the \frontmatter and \backmatter commands. This is why it works: \chapter without the star does 1.put something in the .toc file; 2.if the secnumdepth counter is greater than or equal to zero, increase the counter for the chapter and write it out. 3.write the chapter title. ------------------------------------------------------------------------ SWPlace does not use the syntonly package or the Include command. it does use the INPUT command. ------------------------------------------------------------------------ From the NoT os short intro to Latex 2e \include {chap2.tex, chap2.tex, chap3.tex} \includeonly{chap2.tex} %This means only chap2.tex will be included. This does not work in SWP. ------------------------------------------------------------------------ For packages: http://www.ctan.org/tex-archive/help/Catalogue/alpha.html \usepackage{boxedminipage} \begin{boxedminipage}[c]{0.6 \linewidth} %box is .6 of entire line text that I want to box, such as a game description, goes here. \end{boxedminipage} ------------------------------------------------------------------------ \let\footnote=\endnote This is for use with the ENDNOTES package. ------------------------------------------------------------------------ "Left side text \hfill right side" The hfill command is good for putting text on each side of a page. " ~ \hfill right side" The tilde ~ can be used for a space. "\;" works just as well. ------------------------------------------------------------------------ \begin{tabbing} % set the tab positions \hspace {1in} \= \hspace {1in} \= \hspace {1in} \= \hspace {1in} \\ one \> be \> due to \> differences,\\ one \> to \> reputation \> the sort\\ \end{tabbing} ------------------------------------------------------------------------ \begin{verbatim} \end{verbatim} for unformatted text. ------------------------------------------------------------------------ MY STANDARD FORMATTING HEADER: \documentclass[12pt]{article} % pdflatex -job-name=copying-rasmusen temp.tex %\includegraphics[width=150mm]{fig07-01.jpg} \usepackage{graphicx} \usepackage{amsmath} \usepackage{amssymb} \reversemarginpar \topmargin -1in \oddsidemargin .25in \textheight 9.4in \textwidth 6.4in %\input{tcilatex} \begin{document} \parindent 24pt \parskip 10pt %\begin{Large} {\bf An Economic Approach Copyright } \\ \end{Large} %\bigskip %WORKING PAPER\\ (Comments welcomed) %\bigskip % 20 August 2005 \\ %Dan R. and Catherine M. Dalton Professor %\newpage %\begin{raggedright} %\parindent 24pt %\parskip 10pt %\end{raggedright} ------------------------------------------------------------------------