-
How to include the LaTeX and BibTeX logos in your document
\documentclass{article}
\usepackage{doc}
\begin{document}
The LaTeX logo: \LaTeX
The BibTeX logo: \BibTeX
\end{document}
-
How do I cite an author's name (from a BibTeX entry) in my document without re-typing his/her name?
I use the natbib package. This uses ordinary .bib
input, but provides a variety of output macros:
% This file is test.tex. test.bib also exists in this directory
\documentclass{article}
\usepackage{natbib}
\begin{document}
\citeauthor{jolly04example} explains how to include bibliography material
into using natbib. See \citep{jolly04example} for more examples.
\bibliographystyle{abbrvnat}
\bibliography{test}
\end{document}
The complete list of \cite* macros can be found in
the package readme file.
-
How do I ask Vim to convert the current window of syntax highlighted LaTeX into HTML suitable for displaying on my web pages?
The command from within Vim is :TOhtml. See :help convert-to-HTML for example invocations.
Not only can Vim output HTML suitable for older browsers, it can also generate CSS style code.
-
How do I write 'smart' macros that give one output inside math mode and another in normal mode?
Use \ifmmode:
\documentclass{article}
\def\test{\leavevmode\ifmmode math \else normal \fi}
\begin{document}
\test
$\test$
\end{document}
-
How do correct spacing around custom macros in math mode?
Use \math* macros (see page 206 of the LaTeX companion):
\documentclass{article}
\begin{document}
\begin{math}
\begin{array}{l}
a trial b \\
a \mathbin{trial} b
\end{array}
\end{math}
\end{document}
-
How do I handle long equations? Can I split them onto two lines?
Use the split environment provided by amsmath:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\code}[1]{{\tt #1}{}}
\newcommand{\ObjType}[4]{\ensuremath{ObjectType\{#1_{#3}:#2_{#4}\}_{1 \leq #3 \leq #4}}}
\newcommand{\eif}{\mbox{\bf~~if~~}}
\newcommand{\eand}{\mbox{\bf~~and~~}}
\newcommand{\SubType}[2]{\ensuremath{#1~\mbox{\code{<:}}~#2}}
\begin{document}
\begin{equation}
\begin{split}
\SubType{\ObjType{m}{S}{j}{m}}{\ObjType{m}{T}{i}{n}} \\
\eif n \leq m \eand \mbox{for each~} i \leq n, \SubType{S_i}{T_i}
\end{split}
\end{equation}
\end{document}
-
How do I change the format of captions for figures? Can I change the word 'Figure'?
Use ccaption:
\documentclass{article}
\usepackage{ccaption}
\captionnamefont{\bfseries}
\captiontitlefont{\small\sffamily}
\captiondelim{ --- }
\hangcaption
\renewcommand{\figurename}{Fig.}
\begin{document}
\begin{figure}
Test
\caption{This is a test}
\end{figure}
\end{document}
For more details, see the ccaption package.
Follow the installation instructions at the bottom of the page.
-
Can I create figures within figures (or sub-figures) labelled 'Figure 1(a)' etc?
Use subfigure:
\documentclass{article}
\usepackage{subfigure}
\begin{document}
\begin{figure}
\subfigure[Caption for first subfigure]
{
\label{FirstSubFigure}\fbox{Contents of first subfigure}
}
\subfigure[Caption for second subfigure]
{
\label{SecondSubFigure}\fbox{Contents of second subfigure}
}
\caption{Caption for the overall figure}
\label{OverallFigure}
\end{figure}
Reference the overall figure: \ref{OverallFigure}.
Reference the first subfigure: \ref{FirstSubFigure}.
Reference the second subfigure: \ref{SecondSubFigure}.
\end{document}
For more details, see the subfigure package.
Download all the listed files and type make to extract the package and related material.
-
How do I modify the LaTeX search path to include directories that contain my own
.{cls,sty} files?
Under Linux/UNIX, set the TEXINPUTS environment variable. TEXINPUTS is the search path for resource files
including graphics, packages and document classes.
export TEXINPUTS=".:~/path/to/add:"
export TEXINPUTS=".:~/path/to/add:/second/path/to/add:"
export TEXINPUTS=".:~/path/to/add/:"
export TEXINPUTS=".:~/path/to/add//:"
Note: the commands shown are for setting environment variables within
the Bash
shell. Use setenv (check invocation in man
pages) for the Tcsh shell.