Finally I’ve finished my Master thesis and presentation. — although I was required to use a PPT template for my presentation thus I couldn’t use Beamer, I finished the whole thesis using LaTeX/Metapost, and this time I become completely a fan of MetaPost and learned again a little more about LaTeX, especially the convenience brought by several useful packages. Here I note them down together with some simple examples. In case you need to write a paper or thesis, they may help you a lot to produce a decent looking document.
graphicx
This is a very common package to include images into the document. And quite often, you may need to let the package look for image files in directories not the same as where the .tex file is stored. Therefore you need this small trick at the preamble part:
\graphicspath{{metapost/}{gnuplot/}{figures/}}
Here I just let it look for images from 3 sub-directories, you can also use absolute path.
amssymb, amsmath, amsthm
These 3 packages are essential if what you plan to write about contains lots of mathematic equations, definitions etc. They offer features to align/position the equations nicely and also allow you to define you own theorem/theorem style.
% define new theorem style and new theorem
\newtheoremstyle{example}%
{}{}{}{\parindent}{\bfseries}{:}{.5em}{}%
\theoremstyle{example}
\newtheorem{ex}{Example}[chapter]
listings
If you like me need to include some source code snippet into the text, this package can help you format the code properly according to the programming language.
By default it doesn’t use a monospaced font, which I feel a bit weird, so I changed it globally at the preamble part
\lstset{language=C,basicstyle=\ttfamily,captionpos=b,tabsize=4,showspaces=false}
You can notice I also define the default lanuage as C so it will use special font style for key words in C.
subfig
Sometimes you need to have to graphs in one figure shown as (a) and (b), this package allows you to flexibly control the sub-figures including their captions, it also provide a command to let you refer to a specific sub-figure when you need to.
\begin{figure}
\centering
\subfloat[][Load]{\includegraphics[scale=1]{mt-load}}%
\qquad
\subfloat[][Load and Store]{\includegraphics[scale=1]{mt-load-store}}
\caption{Multi-thread Data Load/Store (Data item size: 128 Byte)}
\label{fig:mt-load}
\end{figure}
fancyref
If you would like to save the effort of typing in all the
“chapter/section/page” text before you use the \ref command, and if
you would like to make them fancier, e.g. section 4.2.3 on page
14 (text in bold are added automatically by the package), you can
try this package out. It just needs you to prefix all you labels
according to the type of environments they point at. For example, by
default chap: for chapter, fig: for figure etc.
Moreover, you can to define new prefixes for the environments
fancyref doesn’t know. In my case, it doesn’t cover the lstlisting
environment and example theorem. So I have them defined as
\newcommand*{\fancyreflstlabelprefix}{lst}
\frefformat{\fancyrefdefaultformat}{\fancyreflstlabelprefix}{list\fancyrefdefaultspacing#1}
\Frefformat{\fancyrefdefaultformat}{\fancyreflstlabelprefix}{List\fancyrefdefaultspacing#1}
\newcommand*{\fancyrefexlabelprefix}{ex}
\frefformat{\fancyrefdefaultformat}{\fancyrefexlabelprefix}{example\fancyrefdefaultspacing#1}
\Frefformat{\fancyrefdefaultformat}{\fancyrefexlabelprefix}{Example\fancyrefdefaultspacing#1}
booktabs, longtable
These 2 packages will help you make better looking tables, the first
will provide commands for different borders (top/middle/bottom) and
the width of them are adjusted to make the table look more
professional. longtable, as the name suggested, will help you fit
long table across pages with optionally repeated header anf footer.
Besides these packages, I also practices this time to organize the
whole document more effeciently by writing each chapter in a
independent file and use the \input command of LaTeX to include them
in the main (master) .tex file. This will let you better control the
structure of the document and easily product partial document with
selected chapters. Also the AUCTeX package for Emacs has support
to such multi-file arrangement. It can write some meta information
inside the slave tex files (files you include), then let you jump from
a slave file directly to the master one, and you can also compile the
whole document right inside the slave file. (C-c C-c).
0 comments:
Post a Comment