Some useful tips and tricks in LaTeX.

Here are some useful tips and tricks in making your LaTeX document look like you want it to. I've collected these mainly from comp.text.tex, but some are from other sources. Note that the authors' e-mail addresses are protected with a XYZZY that must be removed.

If you don't find the answer to your problem here, the UK TeX Users Group maintains a TeX FAQ. And if you're looking for general information about distributions and packages, you might want to search in the UK TeX archive. Anyway, this is my own collected list:

Equations, math mode

Figures

Fonts

Page or text layout

Headers and footers

Chapters, sections and references

Tables

BibTeX

Miscellaneous

Literature

If you've got a problem, the solution is probably described in one of these books.



Equations, math mode

Top of document


How to achieve bold and italics in math-mode

Source: tim@XYZZYmaths.tcd.ie (Timothy Murphy)

Q:

is there any way, using a bold AND italics font in math-mode?

A:

\usepackage{amsbsy}
...
\[
\boldsymbol{\Gamma} = 3.
\]
Top of document

How to make $x^i_j$ different from $x_j^i$

Source: Mike Piff <M.Piff@XYZZYshef.ac.uk>

Discussion:

In some cases, it might be better to use $X^j\vphantom{X}_i$ and $X_i\vphantom{X}^j$, respectively, so the subscript and superscript will both know about the height and depth of the preceding character. For an X, it may not make a big difference, but in other cases it might.

MP:

Surely, as I mentioned in a separate, detached thread, it is more logical to use

$X_i^{\phantom{i}j}$ and $X^j_{\phantom{j}i}$?

Are there any known bugs in this? (As for \vphantom?)

Top of document

Do you have troubles using manual sizing of bracket symbols

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

[I have a problem] related to \bigg.....

A:

The LaTeX distribution contains a standard package, exscale. after \usepackage{exscale} then \big and friends work as expected with class options like 12pt, and size commands like \large.

Top of document

\prod and \int in \frac

Source: Alain Kessi <alain.kessi@XYZZYpsi.ch>

Q:

if i use a \prod or \int within a \frac{}{} they end up very small with the sub/superscripts alongside rather than above or below.

A:

\frac{\displaystyle \int_a^b dx f(x)}{\displaystyle \prod_{i=1}^{\infty} a_i}
Top of document

A wider hat than \widehat

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

How do I get a wider hat (and tilde) than \widehat and \widetilde?

A:

If you use the amsfonts package (and the ams fonts) you get a wider wide hat, but it is still not very wide. Alternatively (As you would have known if you were a member of UKTeX as it was described in the last Baskerville) The rather nice yhmath package of Yannis Haralambous provides much bigger wide hats tildes and similar widgets.

Top of document

Aligning operators in a system of equations

Source: David Kastrup <dak@XYZZYmailhost.neuroinformatik.ruhr-uni-bochum.de>

Q:

What is the preferred way for aligning the operators in a system of equations? I have tried various LaTeX and AMSTex environments such as eqnarray and align but I can't find a good way of aligning systems of equations (other than on the = sign) when coefficients are absent.

A:

Use the alignat environment with empty spacing between "equation sets", namely, && instead of just & to separate alignment points.

Top of document

Binominal sign without AMSTeX

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

As a matter of fact, I try to avoid plain TeX commands in LaTeX; but I had to use \choose for binomial coefficients.

What is the LaTeX recommended command (if any :-) to use instead of {a \choose b} ?

N.B.: I do NOT want to \usepackage{amstex} just to define \binom (Companion, page 229).

A:

The recommended way is to go

\def\binom#1#2{{#1\choose#2}}

and then use \binom{a}{b}

oops! I meant to say of course

\providecommand{\binom}[2]{{#1\choose#2}}

As David Kastrup has pointed out earlier in this thread at a package level LaTeX programmers do need to use TeX primitives. However the important thing is *documents* there one should try to keep a consistent and clean syntax.

Top of document

Figures

Top of document


Aligning eps figures at the center

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

I need to put two eps files generated by matlab (similar figure) to latex file. But the bounding boxes of these two is different so I have trouble alligning them at the center. Can anyone help? Thanks a lot!

A:

put each of the graphics inclusion commands inside a \parbox, the two \parboxes will align on their centres unless you use the optional [t] or [b] argument.

Top of document

Troubles using the epsfig package

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

It seems that eps files are a bit easier to get in and are more easily scaled with the graphicx package rather than with the standard package. As for syntax which worked, here are a couple of variations:

...
\usepackage{epsfig}
....

A:

The epsfig package really is not recommended for new documents. It is there to give some kind of compatibility with the past, and with the LaTeX Companion book which was printed before the graphics package was finished.

Using \usepackage{graphics} or \includepackage{graphicx} will provide an interface that is better documented and better tested.

Top of document

How do I make the caption title bold

Source: Alain Kessi <alain.kessi@XYZZYpsi.ch>

Q:

How do I make the "Figure xxx" in the Figure caption bold? Editor's specs for a paper was, 12pt size with Figure captions 10pt (\small works OK here) and the "Figure xxx" in bold.

A:

Have a look at the caption2 package on CTAN (ftp.cdrom.com or ftp.tex.ac.uk).

Top of document

Different font in caption

Source: Alain Kessi <alain.kessi@XYZZYpsi.ch>

Q:

In LaTeX, a \caption command within a figure environment will cause the word "Figure" followed by an integer (followed by whatever argument is given to \caption, as the caption's text) to be printed. My question is, how does one *locally* alter the font size of the font LaTeX uses for the word "Figure" and the following integer?

A:

Have a look at the caption package, available on CTAN (ftp.cdrom.com).

Top of document

Norwegian letters in gnuplot plots

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

[description of trouble transferring Norwegian letters from gnuplot to LaTeX]
PS: I have tried the supposedly failproof {\aa} for å. Still no reaction.

A:

Well å is supposed to turn itself into \aa, so both of these are equally `supposedly failproof'

The problem is in fact your preamble, [...], or rather a combination of your preamble and the stuff that gnupot added.

Your preamble says \usepackage[T1]{fontenc} which tells LaTeX you are using T1 encoded fonts (and in particular tells LaTeX where to find \aa).

Unfortunately the autogenerated code you showed had

\font\gnuplot=cmr10 at 10pt
\gnuplot

which is a horrible TeX primitive font load, which slips into the old TeX encoding without informing LaTeX of anything....

So solutions are to either just remove that all together, or to put \fontencoding{OT1}\selectfont before the start of the gnuplot stuff to tell LaTeX that you are using OT1 encoding at that point. The inputenc based latin1 encoding should work unchanged with either the T1 or OT1 font encoding. (As you are in Norway, in Iceland there is the problem that the OT1 encoding misses thorn and eth.)

PS
I think you should report this as a bug to the maintainers of gnuplot.

Top of document

Placing figures HERE!

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

I want to stop my figures and tables from floating and in th past I have used Here.sty, but for some reason it is giving me an error with latex2e. Does anyone know if this useful style file has been revamped per the latex2e conventions. Any pointers would be greatly appreciated.

A:

I went off the idea of here.sty. It always was better really to set the float placement parameters in a way such that the floats can be set, rather than using the sledgehammer approach the here.sty used to disable the entire mechanism.

So I got the ctan archives to delete here.sty (even the old version that worked with 2.09) rather than do the update to 2e.

LaTeX now has a ! possibility and [!ht] probably does what you want and has the big advantage of guaranteeing that floats stay in the right order.

However if you are really keen on the [H] for HERE! from here.sty it made its way into float.sty which was updated for the current LaTeX, so you can use that. Look on ctan; `quote site index float' should find it. Float package has some other nice features so you may want it even if you don't use [H].

Top of document

Framing a Postscript file

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

I have used the lines below to include and frame a postscript image in my latex2e document. The result, however, is the image overlayed on the top left corner of the box. In other words, the image does not get framed properly. Can somebody give me an insight?

\fbox{\centerline{\includegraphics[angle=90,width=5.0in,
height=3.0in]{xcon1.ps}}}

A:

The construction \fbox{\centerline{{..}} is wrong (but not the cause of your problem) \centerline make a TeX box the full width of the line, \fbox makes a box that is wider than that by 2 times (\fboxrule + \fboxsep) so the whole thing is wider than the textwidth and so bound to make an overfull box that sticks out on the right.

The way to do make a full width frame with stuff centred in it is to go

\noindent\framebox[\textwidth]{....}

If the image is not staying inside the box it means that the bounding box in the original file is wrong, which is a *bug* in the software that produced the PS file. You can give an alternative bounding box by using the bb=1 2 3 4 key. What numbers you should use instead of 1 2 3 4 depend on the file you have. There exists software to calculate this, or just print out your file xcon1.ps and measure the bottom left and top right coordinates in inches, and multiply by 72 to get these coordinates in points.

Top of document

Centering of too wide figure

Source: David Carlisle <carlisle@XYZZYklopfer.zdv.uni-mainz.de>

Q:

I am using the graphicx package for including Figs:

\begin{figure}[htbp]
  \begin{center}
    \leavevmode

    \includegraphics[width=15cm]{somefig.eps}
    
    \caption{Somecaption}
    \label{fig:somefig}
  \end{center}
\end{figure}

However, the Fig is slightly broader and doesn't fit into the default margins. It is aligned with the left margin. Is there a way of placing it in the center (without changing the text margins) ?

A:

> \begin{figure}[htbp]
>   \begin{center}
>     \leavevmode
> 
>     \includegraphics[width=15cm]{somefig.eps}

don't do that!

you ised to need \leavevmode in fromt of the old \psfig command from the psfig package due to a bug in its LaTeX support, but even there, it should be *directly* in front of the command, not with a blank line between.

As you have it you have a `white' paragraph before the figure. The simple rule is. Don't use \leavevmode in LaTeX documents, it should never be needed.

To answer your question, make a list environment that sets the margins appropriately, eg copy the quote environment, but change the signs so the margins are decreased not increased.

Top of document

Too many unprocessed floats

Q:

I get the error message `too many unprocessed floats'. What should I do?

A:

LaTeX can only handle 18(?) floats before deciding how and where to print them. There are at least two solutions. First, you can enter some text between your floats. If that isn't an option, let LaTeX process it's floats by forcing a new page with \clearpage.

Top of document

Fonts

Top of document

How can I get boldface greek letters

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

\newcommand[1]{\bm}{\mbox{\boldmath{$#1$}}}

I have used that command quite succesfully. There is one thing I wanted to ask, namely how to get the sizes right when using bold greek in subscripts or superscripts. How should the newcommand be defined that the sizes would automatically be right ?

A:

The \boldsymbol command in the AMS LaTeX packages does work correctly in sub and superscripts.

Top of document

Is there a font suitable for Lagrange?

Source: Alain Kessi <alain.kessi@XYZZYpsi.ch>

Q:

On different math. publications, there is a very pretty font, (somebody told me, it is called like cal24 or something similar), but we don't know now to put it in our LaTeX document.

A:

One such font is available through the \mathcal command or the \cal switch. Another, which for some purposes (such as Lagrangian) looks better, is the rsfs font, available on CTAN (ftp.tex.ac.uk or ftp.switch.ch), along with the package mathrsfs which makes it available through the \mathscr command.

Top of document

How to produce a dropped capital

Source: Alain Kessi <alain.kessi@XYZZYpsi.ch>

Q:

I wonder if there is a macro out there to produce 'dropcap' (very large first capital letter of a paragraph, dropping) like those in newspaper or magazines.

A:

Look for "drop.sty". Or dropcaps.sty. Or initials.sty.

As for the font, have a look at the yinit font:

\documentclass[12pt,a4paper]{article}
\usepackage{drop}
\font\largefont=yinitas

\begin{document}

\drop{D}OES THERE EXIST a field with 4 elements?
\end{document}
Or use
\font\capfont=cmbx12 at 24.87 pt % or yinit, or...?
\newbox\capbox \newcount\capl \def\a{A}
\def\docappar{\medbreak\noindent\setbox\capbox\hbox{\capfont\a\hskip0.15em}%
\hangindent=\wd\capbox%
\capl=\ht\capbox\divide\capl by\baselineskip\advance\capl by1\hangafter=-\capl%
\hbox{\vbox to8pt{\hbox to0pt{\hss\box\capbox}\vss}}}
\def\cappar{\afterassignment\docappar\noexpand\let\a }

\cappar Once upon a time ...
Top of document

Helvetica as standard font

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

I am using LaTex Version 2.09 and i have to print a document in HELVETICA. Is there a (easy) way to do this?

A:

By far the easiest way is to first update your LaTeX (the version you have must be dated at the very latest March 1992) and then go

\documentclass{article}
\renewcommand\sfdefault{phv}%               use helvetica for sans serif
\renewcommand\familydefault{\sfdefault}%    use sans serif by default
\begin{document}
hello
\end{document}
Top of document

Norwegian letters in LaTeX input

Q:

How do I make LaTeX accept Norwegian (or European) letters in my .tex-file?

A:

In your preamble, use
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
To make Emacs accept Norwegian letters, put in your .emacs
(standard-display-european t)
(set-input-mode (car (current-input-mode)) (nth 1 (current-input-mode)) 0)
Top of document

Is there an easy way to install new fonts

Source: tim@XYZZYmaths.tcd.ie (Timothy Murphy)

Q:

I was wondering if some kind soul could let me know the *simplest* way to actually install a new font for LaTeX under unix. I can find lots of (presumably) nice fonts on the CTAN sites, but seemingly no concise instructions on how to install them. I would imagine that I have to put them in some directory, which is pointed to by one or more envirnonment variables, and then TeX should call Metafont when needed. Or is there more to it than this?

A:

It depends on what version of TeX/LaTeX you are using, and also the format in which the fonts are given.

Assuming that the fonts are in *.mf format, then all you probably need to do is to create the appropriate .tfm file(s) and leave it/them in an appropriate place, eg where other .tfm files are. Thus if your font is foo.mf you might say

% mf "\mode=cx;mag=1;input foo"

This should create foo.tfm and foo.*gf . You can ignore the latter. Now put foo.tfm in the same directory as other .tfm files.

LaTeX only needs the .tfm files, but when you come to use dvips or xdvi the PK files will be required. These are usually made automagically by running the script MakeTeXPK, so you need do nothing.

One last point. Some systems keep a "database", probably called ls-R, to speed up looking for fonts, etc. If yours does you may need to run some program to update "ls-R".

Top of document

Calligraphic font

Source: mathnews@XYZZYgraves.maths.tcd.ie

Q:

Could anybody tell me how to type in LaTeX a calligraphic capital L, the one used to designate L_k function spaces (\mathcal{L} is not "calligraphic" enough...)

A:

Ralph Smith's rsfs fonts are very popular. There is a package mathrsfs.sty to use them at the CTANs.

\documentclass{artilce}
\usepackage{mathrsfs}
...
\[
\mathscr{L}_k ...
\]

Of course you need the rsfs fonts too, also available at the CTANs eg

ftp ftp.tex.ac.uk
ftp> quote site index rsfs

to find where they are.

Top of document

How do I produce a plain tilde character?

Q:

How do I produce a plain tilde character?

A:

\textasciitilde


Page layout

Top of document


Breaking lines after /

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

[the document text extended into the right margin]

.... sport/utility

A:

if you used sport\slash utility you would allow \TeX to break the line after the /

Top of document

\marginpar without considering item as float

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

What I want to do is to define a command like \marginpar that does the job but that does not consider its items as floats. It should directly put the item in the margin. I don't care if two items fall onto each other, because I can solve that by hand.

A:

You need to use \vadjust (LaTeX purists will tell you at \vadjust is a TeX primitive not a LaTeX command, but tell them it's OK to use primitives as long as they are not called \over)

A simple version is

\newcommand{\mymarginpar}[1]{%
\vadjust{\smash{\llap{\parbox[t]{\marginparwidth}{#1}\kern\marginparsep}}}}
Top of document

Double line spacing

Source: Alain Kessi <alain.kessi@XYZZYpsi.ch>

Q:

Hi! The LaTeX manual has succeeded in completely confusing me. I'd like to make a double-spaced document (because my profs want it that way), and the manual mentions that I should use the \baselinestretch command. How? It's not very clear, but then i am only marginally experienced! Any help on this would be much much appreciated. Thanks!

A:

You can use
\renewcommand{\baselinestretch}{1.5} % or 2, or whatever

If this is in your preamble, then it applies to the entire document (also the captions and footnotes). If you want just part of your document double-spaced, then you'd better use the setspace package or, if you insist on using \baselinestretch, you need to follow it by a \normalsize command to update all the variables that depend on \baselinestretch.

Source: Alain Kessi <alain.kessi@XYZZYpsi.ch>

Q:

What's the easiest way to change the line-spacing globally in a TeX document? Also, what's the easiest way to do this from a certain point on?

A:

The LaTeX Companion tells you to use
\renewcommand{\baselinestretch}{1.66}\normalsize

The figure 1.66 (and not 2) should give double spacing. The size changing command is necessary for the \baselinestretch change to take effect.

Have a look also at the setspace package, available on CTAN (ftp.cdrom.com). If you don't want captions and footnotes double spaced, this may be the way to go.

Top of document

List of tables and figures on the same page

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

I would like to have both the List of Tables and the List of figures on the *same* page, since they er both raher small.

A:

put each of them into a minipage environment, then you could have them both on the same *line* if you wanted...

Top of document

How to produce a "watermark"/EPS graphics behind text

Source: bernard@XYZZYmaggie.cs.mcgill.ca (Bernard DESRUISSEAUX)

Q:

How do I include an encapsulated postscript file so that the graphics appear behind the text? (the formatting of the text should *not* be affected by the graphics)

A:

This macro works with dvips.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Macro         :   \BackgroundEPS{filename}{tx}{ty}{s}
%-----------------------------------------------------------------------
% Description   :   Display an EPS file in the background of the
%                   current page.
%-----------------------------------------------------------------------
% Author        :   Bernard Desruisseaux (bernard@XYZZYcs.mcgill.ca)
%-----------------------------------------------------------------------
% Usage         :   \BackgroundEPS{pic.eps}{80}{100}{2}
%                   \BackgroundEPS{"`gunzip -c pic.eps.gz"}{80}{100}{2}
%                   \BackgroundEPS{"`zcat pic.eps.Z"}{80}{100}{2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\BackgroundEPS#1#2#3#4{%
    \special{ps: @beginspecial @setspecial initmatrix
                0.9 setgray #2 #3 translate #4 dup scale}
    \special{ps: plotfile #1}
    \special{ps: @endspecial}
}
Top of document

I need to have more space between my columns

Source: tim@XYZZYmaths.tcd.ie (Timothy Murphy)

Q:

I'm using the 11pt,twocolumn,landscape options to the book class; that is:
\documentclass[11pt,landscape,twocolumn]{book}
I need to significantly increase the space between the two columns. Could someone please give me some pointers on how to do this?

A:

\addtolength{\columnsep}{5mm}
Top of document

Formatting program languages

Source: Alain Kessi <alain.kessi@XYZZYpsi.ch>

Q:

I am looking for a style file which can format my C code without any retyping or adding things to the original stuff. I have looked at 'ptogram.sty'. It is not the one I am after, since, first it is more or less Pascal type, and secondly it needs key words to be typed as commands.

A:

Have a look at the lgrind program, available on CTAN, which will turn your source from any of a number of programming languages to LaTeX pretty-printing code

Top of document

Breaking name of URLs in sensible places

Source: Alain Kessi <alain.kessi@XYZZYpsi.ch>

Q:

Does anybody know of a style file that can be used with LaTeX so that it will break a URL in sensible places.

A:

The name of the package is url, and it is available on CTAN (ftp.cdrom.com) as
macros/latex/contrib/other/misc/url.sty
Top of document

How to produce a degree symbol

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

Hello there, I want to use a degree symbol with Latex2e and had simply defined the command
\raisebox{0.5ex}{\tiny o} 
but when I try to place it in a figure caption it is not happy

A:

Most people use
\newcommand\degrees[1]{\ensuremath{#1^\circ}}
...
\degrees{90}

You'd need \protect\tiny but it's better to use ^\circ anyway.

Top of document

I wish to have smaller text in tables

Source: asnd@XYZZYerich.triumf.ca (Donald Arseneau)

Q:

Is there a way for the font size in figure and table captions to be one step smaller than the rest of the text?

A:

Don't you want the whole table to be smaller?
\renewenvironment{table}
               {\@float{table}\small\linespread{1}}
               {\end@float}

etc. for figure figure* table*

Unfortunately, there is a (stupid!) explicit \normalsize in the definition of \@caption, which you will have to remove:

\long\def\@caption#1[#2]#3{\par\addcontentsline{\csname
  ext@#1\endcsname}{#1}{\protect\numberline{\csname
  the#1\endcsname}{\ignorespaces #2}}\begingroup
    \@parboxrestore
%%  \normalsize
    \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
  \endgroup}
Top of document

I need to add a half line space

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

How can I add a half line (space) in a table?

A:

use \\[5pt] to add 5pt extra space

Top of document

Correct landscape output

Source: bil kleb <kleb@XYZZYab00.larc.nasa.gov>

Q:

Although I put the command: \documentclass[11pt,landscape]{article}, my document still remains in the portrait mode.

A:

it is unclear what you want: your subject line talks about slides, but your example is for an article?

for slides, i use:

% file: slides.tex
% xdvi -paper usr slides                     % to preview
% dvips -t landscape slides                  % convert to postscript
% ghostview -landscape -swap slides.ps       % view postscript
\documentclass[landscape]{slides}
\begin{document}
\begin{slide}
  Sample slide
\end{slide}
\end{document}
for a landscape article i use:
% file: landart.tex
% xdvi -paper usr landart                    % to preview
% dvips -t landscape landart                 % convert to postscript
% ghostview -landscape -swap landart.ps      % view postscript
\documentclass[11pt]{article}
\usepackage{lscape}%  part of d carlisle's graphics package
\begin{document}
\landscape   % or \begin{landscape} ... \end{landscape}
Text
\end{document}
Top of document

Headers and footers

Top of document


I want a special header

Source: Piet van Oostrum <piet@XYZZYcs.ruu.nl>

Q:

I have a question (and a challenge) for all of the latex gurus out there. I have a professor that wants to generating headings for his latex documents that look like this:

Economics 309                                           H. Farber
Spring 1997                                             Page 2 of 15

A:

Use the fancyhdr and lastpage packages
\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}
\lhead{Economics 309\\Spring 1997}
\rhead{H. Farber\\Page \thepage~of \pageref{Lastpage}}

That's it. Depending on your document, a \thispagestyle{fancy} may also be needed for the first page.

Top of document

Date in header

Source: Piet van Oostrum <piet@XYZZYcs.ruu.nl>

Q:

I'm trying to set my latex document so that the current date will appear in the header of each page. The LaTeX manual has mentioned this is some kind of \pagestyle{myheadings} with a \markboth{} somewhere in there, but I'm not sure how to put it together to make it work.

A:

\markright{\today}
or
\markboth{Some Title}{\today} or
\markboth{\today}{Some Title}

For even more control, use the fancyhdr package.

Top of document



Chapters, sections and references

Top of document


Footnote in heading without entry in TOC

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

could anybody tell me how to make a footnote to the section heading without placing it into the Table of content?

A:

\section[aaa]{aaa\footnote{bbb}}
Top of document

Automatic list of symbols

Source: Alain Kessi <alain.kessi@XYZZYpsi.ch>

Q:

Hi. Is there any automatic way of making list of symbols in Latex2e. I appreciate any suggestions.

A:

A list of symbols (nomenclature, acronyms, abbreviations) can be generated using There is also an abbrev.sty on Lamport's WWW page:

http://www.research.digital.com/SRC/personal/Leslie_Lamport/latex/latex.html

or use the following code (unfortunately, I don't remember who was the author's name and therefore am unable to give him/her credit):

\ifx\documentclass\usepackage % true after \begin{document}
   \begin{list}{}{\leftmargin=2cm
                  \labelwidth\leftmargin\advance\labelwidth-\labelsep
                  \def\makelabel##1{##1\hfil}}
   \def\EndThisFile{\end{list}}
   \renewcommand\newsymbol[4][]{\item[#2] #4}
   \renewcommand\otherdef[3][\relax]{\item[#2] #3}
   \index{ @Physical Symbols}
\else
   \newcommand\newsymbol[4][]{\def#2{%
       \index{ @Physical Symbols!#1\protect#2@$#3$}%
       \ensuremath{#3}}}
   \newcommand\otherdef[3][\relax]{\ifx#1\relax\else\let#1#2\fi}
   \let\EndThisFile\relax
\fi

\newsymbol{\Cd}{C_D}
          {Depletion layer capacitance}

\newsymbol{\Cm}{C_m}
          {MOS capacitance per unit area}

\newsymbol{\Cox}{C_{ox}}
          {Oxide capacitance, $\Cox = \eSiO2/\dox$}

\newsymbol{\Cs}{C_S}
          {Semiconductor capacitance per unit area}

\otherdef[\CS]{\Cs}
          {Pipeline cell storage capacitor}

\EndThisFile
Top of document

Reference format for sections

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

(see 4.5.3)

Instead I would like to have

(see chapter 4, section 5.3)

but maybe not always.

A:

Something like this?
\documentclass{book}
\makeatletter
\def\breakref#1.#2\relax#3\relax{\def\xchap{#1}\def\xsec{#2}}

\def\fullref#1{%
  \protected@edef\@tempa{\protect\breakref\ref{#1}\relax.\relax\relax}%
  \@tempa
  \protected@edef\xxchap{\thechapter}%
  \ifx\xchap\xxchap
     \sectionname~\xsec\ in this \chaptername
  \else
      \chaptername~\xchap, \sectionname~\xsec
  \fi}

\providecommand\sectionname{section}

\makeatother

\begin{document}
\chapter{aaa}\label{c1}
\section{bbb}\label{s1}

 a full ref (\fullref{s1}) or normal ref (\ref{s1})

\chapter{aaa}\label{c2}
\section{bbb}\label{s2}
 a full ref (\fullref{s1}) or normal ref (\ref{s1})

\end{document}
Top of document

Suppressing page breaks

Source: asnd@XYZZYreg.triumf.ca (Donald Arseneau)

Q:

I have the following code in a document I am writing.
 
These are:\nopagebreak 
\begin{center}
\begin{tabular}{|c|c|c|c|c|}

Where the \nopagebreak is I am getting a page break. How can I suppress it?

A:

\nopagebreak does not suppress the page breaks that are deliberately inserted around environments like {center}. You have three options:

Use {centering} rather than {center} which inserts no extra space and does not add a page break point.

Use \centerline{ } rather than \begin{center}...\end{center} with similar non-spacing.

Put \begin{samepage}...\end{samepage} around the whole mess.

Top of document

Extra space in section title

Source: asnd@XYZZYreg.triumf.ca (Donald Arseneau)

Q:

I am attempting to customise the \section and \subsection commands using \renewcommand.

I want to be able to change the spacing between section no. and the section titles.

A:

\renewcommand\section{%
 \def\@seccntformat##1{\csname the##1\endcsname\hspace{_____}}
 \@startsection{your}{parameters}{here}...
}

\renewcommand\subsection{%
 \def\@seccntformat##1{\csname the##1\endcsname\hspace{_____}}
 \@startsection{your}{parameters}{here}...
}
Top of document

Different numbering style in chapter and figure/table

Source: asnd@XYZZYreg.triumf.ca (Donald Arseneau)

Q:

My thesis must have chapter numbers which occur in the text like so:
....as in Chapter~IV, we see that...
And yet still have figures, tables, equations, and everything else still be numbered in arabic, like so: Figure 4.3.

\renewcommand{\thechapter}{\Roman{chapter}}

But then I noticed that the change occurs for Figures, Tables, Equations, and everything which, of course, makes sense, but is not a satisfactory solution to the problem.

A:

You are just about there. The problem is that tha table, figure, and section numbering are defined in terms of \thechapter, so you automatically get the same style of numbering:

\thefigure =  \thechapter.\arabic{figure}
Now you don't want the same style of numbering, so you can specify the style explicitly, different from \thechapter:
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}
\renewcommand{\thetable}{\arabic{chapter}.\arabic{table}}
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}
Top of document

Prefix appendix with "appendix"

Source: asnd@XYZZYreg.triumf.ca (Donald Arseneau)

Q:

I prefer an appendix heading to be like
Appendix A: The first appendix

A:

Assuming you don't have subsections in the appendix:

\appendix
\renewcommand\thesection{Appendix \Alph{section}}

which puts "Appendix" also in all the \ref commands, or

\appendix
\makeatletter
\def\@seccntformat#1{Appendix\ \csname the#1\endcsname\quad}
\makeatother

Both of these put Appendix before subsection numbers also, like Appendix A.2.

For subsections numbered without a name:

\appendix
\makeatletter
\def\@seccntformat#1{\csname Pref@#1\endcsname \csname the#1\endcsname\quad}
\def\Pref@section{Appendix~}
\makeatother

(better would be s sty or cls file that defined \appendix to do this.)



Tables

Top of document


How to set up 8 points text in a table

Source: piet@XYZZYcs.ruu.nl (Piet van Oostrum)

Q:

I am trying to latex an 8-pt file (a 5-page table of data), but it insists on coming out as 10pt. I use the art8 and xarticle options, but they don't seem to work. It appears to call art10.sty and art8.sty for some reason, and to use art10? Can anyone help me figure out what I am doing wrong? Various relevant info is listed below.

A:

xarticle and art8 are probably not compatible with a modern LaTex. On the other hand if you only want to change the fontsize you can do so with the \fontsize command. If you have your table insize a float (table environment) you must do this after the \begin{table}

\fontsize{8}{10pt}\selectfont

Q:

####The file starts with:
\documentstyle[art8,longtable,lscape,rotate_rokicki,fancyheadings]{xarticle}

A:

Make that:
\documentclass{article}
\usepackage{longtable}
\usepackage{lscape}
\usepackage{rotate_rokicki}
\usepackage{fancyheadings}
Top of document

Rotating tables

Source: piet@XYZZYcs.ruu.nl (Piet van Oostrum)

Q:

Could someone point out the proper way to rotate a table in LaTeX. I have the rotate macro from CTAN. When I try a ...

A:

Do you mean rotate.sty?

Q:

\setbox1=\hbox{
\begin{table}
\begin{center}
\begin{tabular}{c|c}[hbt]

A:

(about the use of [hbt]): is this meant to be the optional parameter for the table environment? It may help if you start with reading the LaTeX doc. Besides that if you leave out the p you may tempt LaTeX to do some nasty things.

Q:

\end{tabular}
\end{center}
\end{table}
}
I get an error. Any help is greatly appreciated!

A:

You can't use a table environment in anything else.

With the rotate package you can do the following:

\newsavebox{\rotbox}

\begin{table}[hbtp]
\sbox{\rotbox}{
\begin{tabular}{c|c}
  a & b \\
\end{tabular}}
\sbox{\rotbox}{%
\begin{minipage}{\wd\rotbox}
\usebox{\rotbox}
\caption{Test}
\end{minipage}}
\rotate[l]{\usebox{\rotbox}}
\end{table}

The \wd\rotbox as the width of the minipage is only useful if the table is wide enough, but I suppose if it wasn't there would be no reason to rotate it.

Top of document

Math column in table

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

Is it possible to have an entire column in math environment in a table? I am creating a list of symbols and I need to put all the symbols in the first column, preferably in math environment.

A:

use the array package, and a preamble of the form
\begin{tabular}{>{$}c<{$}cc}

to have one column of math and two coulms of text.

Top of document

A pagewide table in twocolumn environment

Source: Alain Kessi <alain.kessi@XYZZYpsi.ch>

Q:

I want to insert a table which spans two columns on my twocolumn doc. How can I do that? Thank you for your help.

A:

Both within LaTeX's \twocolumn and within the multicols environment defined by the multicol package (often preferrable to \twocolumn, since it balances the columns on the last page and lets you change between two- and one-column modes without starting a new page), you can insert full-width floats by using the starred form of the float environments: figure* and table*.

Top of document

BibTeX

Top of document


Suppress trailing period (.) after title

Source: boris@XYZZYplmsc.psu.edu (Boris A. Veytsman)

Q:

I'm using the unsrt.bst bib style file.

What I want to do is suppress the full-stop (period) that is placed after the title of an article bibitem in the Bibliography output. (I want to put titles in inverted commas, and have the full-stop come before the `"', i.e. `."' and not `".').

A:

The custom-bib package from CTAN (macros/latex/contrib/supported/custom-bib) allows you to create a customized bst file very easily (it asks ytou a zillion questions about the desired format and then produces a bst file accordingly)

Top of document

Miscellaneous

Top of document


TeX directory structure

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

Info on directory structure wanted!

A:

Look at the Tex Directory Structure documents in ctan archives in /tex-archive/tds/*

If setting up a UNIX TeX installation, I strongly advise the tetex distribution which will automatically unpack into a `tds' structure.

Top of document

CTAN via e-mail

Source: David Carlisle <carlisle@XYZZYma.man.ac.uk>

Q:

I know that following CTAN ftp archives are available:
USA             ftp.shsu.edu
UK              ftp.tex.ac.uk
Germany         ftp.dante.de
Is above mentioned servers has mailserver-addresse ?

A:

The email server ftpmail@ftp.dante.de provides an ftp-like interface through mail. Send a message containing just the line `help' for details of use.

Top of document

Extensions to Emacs and LaTeX

If you're using Emacs and LaTeX, the AUCTeX Emacs extension is something for you. AUCTeX provides an integrated environment for Emacs and LaTeX, with direct jump to source text in encountering errors during compilation. It furhter provides viewing and printing from inside Emacs. Take a look at http://sunsite.auc.dk/auctex/

Top of document

LaTeX FAQ?

Source: rf@XYZZYcl.cam.ac.uk (Robin Fairbairns)

Q:

Is there a LaTeX FAQ?

A:

You can view my (and my committee's) efforts on CTAN in usergrps/uktug/faq, or (somewhat) `animated' at http://www.cogs.susx.ac.uk/cgi-bin/texfaq2html?introduction=yes

Top of document

[English useage] Correct punctuations with abbreviations

Source: real-address-in-sig@XYZZYastrid.u-net.com (Rebecca and Rowland)

Q:

Typographical conventions are not only dependent on the language and the regions, but also on individual publishing house. For example, Oxford adds a full point after abbreviations like Mr/Dr while Cambridge doesn't. (IMHO, when an abbreviation comes after a letter, a full point is put there, when it occurs betweeen letters, an apostrophe is put there!!).

A:

The Oxford guide to English usage says this of abbreviations:

It is usual to indicate an abbreviation by placing a point (full stop) after it, e.g.

H. G. Wells, five miles S. (= south), B.Litt., Kt., Sun. (= Sunday), Jan. (=J anuary), p. 7 (= page 7).

However, no point in used:

  1. With a sequence of capitals alone, e.g. BBC... (and not, of course, with acronyms, e.g. Aslef, Naafi).
  2. With the numerical abbreviations 1st, 2nd, etc.
  3. C, F (of temperature), chemical symbols, and measures of length, weight, time, etc.
  4. Dr, Revd, Mr, Mrs, Mme, Mlle, St, Hants, Northants, p (= penny or pence)
  5. In words that are colloquial abbreviations, e.g. co-op, decaf, demi, recap, trad, vac.
Top of document

How to print out several pages on one sheet

Source: Akim Demaille <demaille@XYZZYinf.enst.fr>

Q:

I would like to print a TeX dvi file in such a way that each printed page contains 4 small pages of my document laid out in a 2 by 2 array. The ideal would be to obtain a Postscript file with the document arranged this way. I have been looking at the dvips documentation, but couldn't find any clue. Can please anybody help?

A:

With dvips you can go up to 2 up, no more.

There are many tools which can help :

In fact you can hit:

a2ps -4 documentation.dvi.gz notes.txt manual.1 main.c -o file.ps

It does The Right Thing

        ftp://www.inf.enst.fr/~demaille/a2ps/
Top of document

Standard, should-be-in-the-bookshelf, LaTeX literature

Top of document

Lamport, L.: LaTeX, a document preparation system.
    ISBN 0-201-52983-1,
    Addison-Wesley, 1994

Kopka, H. and P. W. Daly: A guide to LaTeX2e.
    ISBN 0-201-42777-X
    Addison-Wesly, 1995

Goossens, M., F. Mittelbach and A. Samarin: The LaTeX companion.
    ISBN 0-201-54199-8
    Addison-Wesley, 1994
Are you generating LaTeX documents and tables from data files, like me? If so, you will probably appreciate
Schwartz, R. L.: Learning Perl. ("The Llama book")
    ISBN 1-56592-042-2
    O'Reilly, 1993

Wall, L., Christiansen, T. and Schwartz, R.L.: Programming Perl ("The Camel book")
    ISBN 1-56592-149-6
    O'Reilly, 1996
Top of document

You can contact me at
webmaster@hoiset.net
Valid HTML 3.2!