Hints, Tips & UtilitiesKnow something useful about Unix, emacs, prolog or any of the myriad other computer programs wesuffer from in Informatics? Share your knowledge, and receive not only a warm sense of fulfillment that at last your life has some purpose, but also a bottle of wine. In this issue, we have a handy shell script for choosing the right printer and some LaTex tricks. Automatically choose the nearest printer Put this line: . /usr/local/dai/docs/groups/aisoc/printer.sh in your .xinitrc file, and your default printer will be set to the nearest one. Important: don't leave out the "." at the beginning. If you don't trust us not to insert malicious code later, you can download your own copy of the script. - Seth Golub
LaTeX TricksLaTeX is capable of most things but not always in the most obvious manner. Here are some usefultricks that you might struggle to find in the documentation. I'm not trying to teach you LaTeX there are two routes to that 1) read Lamport's book (or something similar) and 2) deconstruct other peoples documents and then try writing your own. The department guide LaTeX for the horrified is a reasonable place to start (see http://www.dai.ed.ac.uk/dai/computing/software_manuals/latex/).
Dynamically Including Program ListingsYou have written the perfect program wonderful.cc and want to include it your report. Well you could do\begin{verbatim} -- Copy and paste your program to here -- \end{verbatim}However what happens when you suddenly find that your program has a bug or would be even better with some tweak. Then you would have to delete the copy from your report and repaste the new version. In preference you can use the verbatim package. This allows you to have a file printed in verbatim format (ie. looking like a typewriter) at the chosen point of your report. At the head of your document (somewhere before \begin{document}put the line \usepackage{verbatim}Then in the relevant location put \verbatiminput{/hame/perfect/wonderful.cc}Now if you change your program rerun LaTeX will produce your report with the updated program. Rotating Tables and FiguresYou want to include the amazing results that you achieve with the program you wrote. No problem, justput them in a table. Unfortunately with all the conditions and outputs that you need to include you find that the table is to wide for the page. You need to find a way to show it in landscape format whilst leaving the rest of your document alone. Enter the rotating package. As before put \usepackage{verbatim}in the head of your document. This allows you to rotate text, tables and figures in every manner that you're liable to want. To create the table use the sidewaystable instead of table. For example (lifted from the file rotating.tex in the package documentation). \begin{sidewaystable} \centering \begin{tabular}{|llllllllp{1in}lp{1in}|} \hline Context &Length &Breadth/ &Depth &Profile &Pottery &Flint &Animal &Stone &Other &C14 Dates \\ & &Diameter & & & & & Bones&&&\\ \hline &&&&&&&&&&\\ \multicolumn{10}{|l}{\bf Grooved Ware}&\\ 784 &--- &0.90m &0.18m &Sloping U &P1 &$\times$46 & $\times$8 &&$\times$2 bone& 2150$\pm$ 100 BC\\ 785 &--- &1.00m &0.12 &Sloping U &P2--4 &$\times$23 & $\times$21 & Hammerstone &---&---\\ 962 &--- &1.37m &0.20m &Sloping U &P5--6 &$\times$48 & $\times$57* & ---& ---&1990 $\pm$ 80 BC (Layer 4) 1870 $\pm$90 BC (Layer 1)\\ 983 &0.83m &0.73m &0.25m &Stepped U &--- &$\times$18 & $\times$8 & ---& Fired clay&---\\ &&&&&&&&&&\\ \multicolumn{10}{|l}{\bf Beaker}&\\ 552 &--- &0.68m &0.12m &Saucer &P7--14 &--- & --- & --- &--- &---\\ 790 &--- &0.60m &0.25m &U &P15 &$\times$12 & --- & Quartzite-lump&--- &---\\ 794 &2.89m &0.75m &0.25m &Irreg. &P16 $\times$3 & --- & --- &--- &---\\ \hline \end{tabular} \caption[Grooved Ware and Beaker Features, their Finds and Radiocarbon Dates]{Grooved Ware and Beaker Features, their Finds and Radiocarbon Dates; For a breakdown of the Pottery Assemblages see Tables I and III; for the Flints see Tables II and IV; for the Animal Bones see Table V.}\label{rotfloat2} \end{sidewaystable}This method puts the table on a page on it's own. This is probably what you want if your table is that wide. If however you don't want it on a seperate page this can be achieved using the sideways and rotcaption in conjunction with the standard table command. There are some examples you can see for details. There are a couple of points worth noting. The table will not appear
rotated when you look at the
\documentclass[a4paper,12pt,twoside]{article}The command sidewaysfigure works similarly. If you use the epsfig package to include eps files then there is another method for rotating the diagram without changing the caption. This can be achieved by, for example: \begin{figure}[hbtp] \begin{center} \epsfig{figure=test.eps, angle=67} \caption{Test} \label{fig:test} \end{center} \end{figure} Maths TricksIf you have to type much in the way of maths it is worth investigating the AMS-LaTeX packages.Being designed by the American Mathematical Society they cover pretty much anything you are ever likely to need if it isn't provided by the standard LaTeX commands. There is very full documentation available in amsldoc.ps (gzipped), so I will only mention a couple of bits. If you have tried to include text in an equation enviroment then you'll
have found that the result is
$f(x)=\sum_{n>o}{\frac{x}{n^2}}=3 \text{ if the moon is full and } x < 5$and other such pearls of wisdom. If you need a maths symbol and don't know it or have the manual handy, look at maths_guide.ps (gzipped) which includes most of them (I think). Doing wordcountsThere is no particularly good way (that I know of) to do wordcounts of a LaTeX document. Howeverwithin certain limits (which you'd have to be particularly abtuse to violate) the following works reasonably. detex [filename] | wc -wAnd that's all folks. Ian Glover: iangl@dai.ed.ac.uk |
|