[Main] [Academic] [] [Wishes] Tricks Page

# Tricks for and - primarily taken from comp.text.tex and The Em mailing list

### Collected by Daniel Doro Ferrante

#### This page contains various questions and answers about and , which I have collected over the time. The only reason, that I have saved them, is that I found them interessting. They are presented here because you might also find them interessting - if not, don't blame me. When preparring this page I have done a minimum of editing: Of course I have inserted the HTML-codes and then I have tried only to take the parts of the question and answers, that where interessting (some times even omitting the question). There is therefore no gaurantee that the suggested solutions a suitable or even work, but in the last case, they might inspire you to find the right solution. Any comments or suggestions, please mail me!

 Links2Go Key Resource TeX and LaTeX Topic

## Degree sign

\newcommand{\grad}{\mbox{$^{\circ}$}}


ernst wallenborn (wall@phys.chem.ethz.ch)

## Bras and Kets

Use \langle and \rangle. For a bit more quality, use the set of macros I made. The lowercase versions are regular size and the capitalized versions are variable size (depending on the size of the arguments).
% Use $$\Braket{\phi | {\partial^2}\over {\partial t^2} | \psi}$$

\def\bra#1{\mathinner{\langle{#1}|}}
\def\ket#1{\mathinner{|{#1}\rangle}}
\def\braket#1{\mathinner{\langle{#1}\rangle}}
\def\Bra#1{\left<#1\right|}
\def\Ket#1{\left|#1\right>}
{\catcode\|=\active
\gdef\Braket#1{\left<\mathcode\|"8000\let|\bravert {#1}\right>}}
\def\bravert{\egroup\,\vrule\,\bgroup}

Donald Arseneau (asnd@reg.triumf.ca)
Here's one that does the sizing for you automatically.
\newdimen\@tempdima
\newdimen\@tempdimb
\newdimen\@tempdimc
\newdimen\@tempdimd

This is TeX, Version 3.14159 (C version 6.1)
(/home/carlisle/jobpath.tex
Hyphenation patterns for english, german, loaded.
!!!
!!! Full path is /home/carlisle/jobpath.tex  !!!
!!!
)
No pages of output.
Transcript written on jobpath.log.
vummath>

jobpath.tex
\newread\logfile

\wlog{just to get started}

\def\flush{%
\openin\logfile=\jobname.log
\read\logfile to \rubbish % get rid of a \par
\ifeof\logfile
\writerubbish
\closein\logfile
\expandafter\flush
\fi}

\def\writerubbish{%
{\newlinechar\ \wlog{\xx\xx\xx\xx}}}

\def\xx{\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx}
\def\xxx{a b c }

\def\getpath{%
\expandafter\testbracket\jobpathname((\testbracket}

\def\testbracket#1(#2(#3\testbracket{%
\def\jobpathname{#2}%
\ifx\jobpathname\empty
\expandafter\getpath
\fi}

% get the log file started
\flush
\getpath

% see what happened

\immediate\write17{!!!}
\immediate\write17{!!! Full path is \jobpathname\space!!!}
\immediate\write17{!!!}

\bye

David Carlisle (carlisle@ma.man.ac.uk)
There is a litte package filename.sty'' by Bernd Raichle which seems to do that:
% filename.sty  \filename records the current filename
%
% first version: 1 Mar 91 (br)
% last change  : 5 Mar 91 (br)
%
\typeout{Style option filename' <5 Mar 91> (br)}

\let\filename=\jobname
\let\old@@input=\@@input
\def\@@input#1 {\def\file@name{#1}%
\expandafter\file@@input
\expandafter\reset@filename\expandafter{\filename}}
\def\file@@input{\let\filename=\file@name
\old@@input\filename\relax}
\def\reset@filename{\def\filename}

\endinput
% -- end of filename.sty'
%From: raichle@azu.informatik.uni-stuttgart.de (Bernd Raichle)

but I have not tested it (it is rather old).

Jean-Pierre Drucbert

## \csname\uppercase{#1}\endcsname replacement

Peter Galk (galko@trix.genie.uottawa.ca) wrote:
  \def\uccsname#1#2{\expandafter\def\csname\uppercase{#1}\endcsname{#2}}

This of course fails due to the fact that \uppercase doe not work in TeX's mouth. Anybody know how to get the required effect? Well, the following should do just fine:
\def\uccsname#1{\uppercase{\expandafter\def\csname#1\endcsname}}

I have removed #2 from the macro arguments so that you might specify arguments yourself, like in
\uccsname{zappadapp}#1#2{something#1#2}

If you wonder why this should work, read the book concerning \uppercase.

David Kastrup (dak@pool.informatik.rwth-aachen.de)

## Dropping a capital a the start of a paragraf

Here is the style file I have used to typeset fairy tales for my little daughter sometime ago :-) :-)

It is an adaptation from drop.sty targeted to the use with the yinit fonts (in CTAN) and Times-Roman on a PostScript printer. Your mileage may vary...

% From "drop.sty", written by David G. Cantor and published
% Fri, 12 Feb 88, in TeXhax, 1988 #16; then modified for use with LaTeX by
% Dominik Wujastyk, February 17, 1988.
%
% Modified MLO 1994-12-05 :
% - advanced \dimen0 by 0.5em, for use with yinit fonts;
% - the largest declared size for yinit fonts is 24.88; here I define a
%   font"myinit", based on yinit.mf and having all sizes.  The actual
%   size used is \dropcapsheight: the default (40pt) corresponds to 4
%   lines of text with 10pt fonts, and generates a file yinit.310pk
%   through METAFONT. \dropcapsheight can be redefined by the user: e.g.
%   with a command \renewcommand{\dropcapsheight}{48pt} before
%   \begin{document}.

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ydrop}
[1994/12/05 - Dropped capitals for the 'yinit' fonts]

\DeclareFontFamily{U}{myinit}{}
\DeclareFontShape{U}{myinit}{m}{n}{ <-> yinit }{}

\newdimen\dropcapsheight  \dropcapsheight=40pt

\def\dropinitialfont
{\fontsize{\dropcapsheight}{1.2\dropcapsheight}
\usefont{U}{myinit}{m}{n}}

\def\drop#1#2{{\noindent
\setbox0\hbox{\dropinitialfont #1}\setbox1\hbox{#2}\setbox2\hbox{(}%
\global\hangindent\dimen0\global\hangafter-\count0
\hskip-\dimen0\setbox0\hbox to\dimen0{\raise-\dimen1\box0\hss}%
\dp0=0in\ht0=0in\box0}#2}

Maurizio Loreti (loreti@padova.infn.it)

## Paragraphs in multiple columns

I want to typeset the same text in two languages side by side, and I thought that I had devised a suitable environment (using the tabularx and array packages):
....
"! Argument of \TX@get@body has an extra }".

You may be better using the parallel' package from ctan, but if you want to use tabularx for this then note the following text from tabularx.dtx:
This mechanism of grabbing an environment body does have the disadvantage (shared with the AMS alignment environments) that you can not make extension environments by code such as
\newenvironment{foo}{\begin{tabularx}{XX}}{\end{tabularx}}

as the code is looking for a literal string \end{tabularx} to stop scanning. Since version 2.02, one may avoid this problem by using \tabularx and \endtabularx directly in the definition:
\newenvironment{foo}{\tabularx{XX}}{\endtabularx}

The scanner now looks for the end of the current environment (foo in this example.) There are some restrictions on this usage, the principal one being that \endtabularx is the first token of the end code' of the environment.
David Carlisle (carlisle@ma.man.ac.uk)
There is an environment for your purposes. Since it is a short style file (for 2.09) I am sending it in this mail. I think you will find it very easy to adapt for your own purposes.
%% Save file as: MULTICOLPAR.STY        Source: FILESERV@SHSU.BITNET
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  File multicolpar.sty
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% by
% Mauro Orlandini <orlandini@tesre.bo.cnr.it>
% Modified by Max Hailperin <max@nic.gac.edu>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%   This LaTeX style, writes different paragraphs in different columns
% the number of columns is free), as
%   This is the first paragraph  |  This is the second paragraph and its
%   and text follows...          |  own text follows...
%
%   This is the third paragraph  |  This is the fourth paragraph...
%   and text follows...          |
%
% This format is useful for translated articles, in which there is the
% original language in the first column and the translated version in
% the second.
%
% Usage: \begin{multicolpar}{N}
%         ... text ...
%        \end{multicolpar}
%
% where N is the number of columns in which the text will be displayed.
% Warning: Inside the environment, each blank line (ie a \par) will
%          correspond to a paragraph, therefore do not leave blank lines
%          soon after the \begin{multicolpar}{N} command and soon before
%          the \end{multicolpar} command (unless you want so).
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{multicolpar}[1]{\begin{trivlist}\item[]%
\multicolumnparallelparagraphs{#1}{2em}}%
{\endmulticolumnparallelparagraphs\end{trivlist}}

\newcount\columnsleft   \newcount\totalcolumns   \newdimen\separation

\def\multicolumnparallelparagraphs#1#2{%
\totalcolumns=#1   \separation=#2   \let\xpar=\par
\vskip\parskip
\columnsleft=#1\relax
\hbox to\hsize\bgroup
\let\par\nextmulticolumnparallelparagraph
\divide\hsize\columnsleft\relax
\vtop\bgroup}
\def\nextmulticolumnparallelparagraph{%
\egroup
\ifnum\columnsleft>0
\hfil\vtop\bgroup
\else
\egroup
\xpar\vskip\baselineskip\xpar
\multicolumnparallelparagraphs\totalcolumns\separation
\fi}

\def\endmulticolumnparallelparagraphs{%
\egroup
\ifnum\columnsleft>0
\hfil\vtop\bgroup\hbox to \hsize{}
\endmulticolumnparallelparagraphs
\else
\egroup
\xpar
\fi}

Alex Schoenmakers (Alex.Schoenmakers@lhs.be)

## How to Put Something on a Fixed Placed on the Page

Have a look at the fancyheadings package. The koma-script package allows custom page-headers, too. In these you could put objects into arbitrary positions on the page via (0,0)-dimensioned picture environments using vertical and horizontal offsets. You can even decide which go on odd or even numbered pages...

Hans-Juergen Godau (godau@dec2.wi-inf.uni-essen.de)

I tend to use a () picture environment (with size 0) at the start of a page. This will give you a defined origin (determine by the offset and margins etc.) from which you can include graphics etc. at arbitrary positions using the \put command.

It seems wisest to put the picture in a header as the top of page could vary from page to page (eg. in the letter-class). (Added by editor after advise from Roger de Reus).

Roger de Reus (REUS@MIC.DTU.DK)

## Printing Many pages on one

Anyway, for a much more general solution, you should look at Marcel van der Groot's 'quire' macros (a quire is a small booklet), which are macros to arrange arbitrary numbers of pages in the right order for printing. They're part of his Midnight Macros collection, available from CTAN or our FTP server.

Barry Smith, Blue Sky Research (barry@bluesky.com)

David Carlisle (carlisle@ma.man.ac.uk) wrote:
I'm trying to format an index, where the subject can sometimes be fairly long. I'd like to force the text into the first 3 or 4 inches, with at least an inch where there is nothing but leader. An example will clarify:
What I have now:
Here is a short title .................... 24

Here  is  a  long  and  annoying  title  that
won't fit onto one line .................. 25


What I want:
Here is a short title .................... 24

Here is a long  and annoying
title that won't fit onto one
line ..................................... 25

This is a very bad case. No

A paragraph has glue stuck into all sorts of places, and by redefining that gluet we can change the shape of the paragraph. \leftskip is inserted at the beginning of every line; \rightskip at the end; and \parfillskip is put at the end of each paragraph. We normally start with \parfillskip=0pt plus 1fil, to left justify the last line.

So the solution to my problem is to add an inch to my \rightskip, which forces the right edge over 1 inch. And to get my page numbers all the way over to the right, we set \parfillskip to -\rightskip to counteract the \rightskip. Lastly, to make sure the very last line doesn't take advantage of the extended room made available by the \parfillskip, we give the leader a minimum size of \rightskip.

I've put all this stuff together into a parameterized environment and played with \textwidth to stress the example I'm working from.

\newcommand{\leaderfill}{Error}
% This will get redefined below

% #1 is the title, #2 the page number,
% and #3 and optional subtitle or author
\newcommand{\IndexPaper}[3]

\newenvironment{Myindex}[1]
{\setlength\parindent{0pt}
\setlength\rightskip{#1}
\setlength\parfillskip{-#1}
\hskip #1 plus1fil\relax}}
{}

(This used like, collectors note)
\begin{Myindex}{2in}
\IndexPaper{The Phenomenon}{3}{We can put a Subtitle here}
\IndexPaper{The Phenomenon of Being and the Being of
the Phenomenon}{7}{Or maybe an author}
\IndexPaper{The Pre-reflective \emph{Cogito} and the
Being of the \emph{Percipere}}{9}{}
\IndexPaper{The Being of the \emph{Percipi}}{9}{}
\IndexPaper{The Ontological Proof}{21}{}
\IndexPaper{Being-In-Itself}{24}{}
\end{Myindex

With these definitions, the basic shape of the paragraph seems right, but the "at least 1 inch leader" rule can get broken. For example, if I typeset the above example with \begin{MyIndex}{1in}, I get listings like:
The Phenomenon
3
We can put a Sub-
title here

The Phenomenon ............... 3
We can put a Sub-
title here

Todd Hivnor (hivnot@rpi.edu)

Bob Gordon (gordon@euclid.math.temple.edu) writes:
I use the xy-pic drawing package with em. I am able to mage e.g. a format file XYPLAIN.FMT with xy-pic preloaded by saing tex386 -i xyplain.ini', where the contents of XYPLAIN.INI is:
...
The same trick used to work with the old inferior'' . I cannot get it to work with . I tried ini-files such as:
\input latex.ltx
\documentclass{article}
\input xy
\xyoption{v2}
\xyoption{2cell}
\UseAllTwocelss
\xyoption{matrix}
\xyoption{arrow}
\dump

latex.ltx has the command \dump at the end of the file. Thus everything after that gets ignored. There are various ways by which you can get around this, but they all lead to non-portability of documents, and are not to be recommended.

One way is to copy latex.ltx to (say) mylatex.ltx, edit this file to remove \dump near the end, and use mylatex.ltx in your file XYLATEX.INI or whatever you decide to call it. You will then have to modify your batch files, etc. And you won't be able to send your source file to anyone else and have them process it.

Ken Smith (kgs@maths.uq.oz.au)

A better way IMHO is to first make a normal'' format, and then to load it again with initex, together with the required classes, pacakges etc., and dump again. I don't know about xy, but to take a different example, suppose you standard'' documents start off with something like:
  \documentclass[english,german,....,12pt,a4paper]{article}
\usepackage[cp850]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel,mymacros,....}

then it is rather tedious watching dozens of files being loaded every time you write a letter. So you make a format latex'' with (say)

tex386 -i -8 latex.ltx

(this is for em and should also install hyphenation paterns for babel (see the documentation for babel), editors note)

and then a format my_latex'' with tex386 -i &latex my_latex.tex where my_latex.tex contains the above line plus \dump. Then you can comment out these lines and load my_latex.fmt instead. Portability is no problem: Just uncomment the lines and the file is as portable as any other file (which is admittedly not very portable in view of the various font, packages, encoding etc. which are meanwhile in use).

Peter Ryder (ryder@theo.physik.uni-bremen.de)

## Side by side figures

Bruce Wilson wrote:
Can anyone suggest a simple means of placing two figures side by side?
I dont't know, if you consider this as a simple means, but it does work...

the width of the two minipages plus the \hspace should not be more than \textwidth. this assumes you're using graphicx. if not, simply replace \includegraphics[...] by your favorite command to include pictures.

\begin{figure}[ht]
\begin{minipage}{187pt}%\mbox{}
\center{\includegraphics[
%       bb=llx lly urx ury,
%        angle=270,
width=187pt,
%       height=v_length,
%       scale=factor,
%       clip=true/false,
draft=false,
]{...ps}}
\parbox{187pt}{\caption{.....
\label{...}}}
\end{minipage}
\hspace{14pt}
\begin{minipage}{187pt}%\mbox{}
\center{\includegraphics[
%       bb=llx lly urx ury,
%        angle=270,
width=187pt,
%       height=v_length,
%       scale=factor,
%       clip=true/false,
draft=false,
]{....ps}}
\parbox{187pt}{\caption{.....
\label{...}}}
\end{minipage}
\end{figure}

Anonymous

## Source code for the -book

OK, here is the instruction for reproducing the Book using the system that you spent two weeks to install. Be advised that the source of the book is provided by Professor Knuth for EDUCATION purposes only. (But an accidental click on the wrong button inside a GUI environment that fires off a process that you cannot kill, or a print job that ties up the printer for several hours can happen, especially if you are in the early stages of learning. :) )
1. You need the manmac.tex file (which is usually distributed with .)
2. You need all the *.tfm files called for by texman.tex (this includes some fonts that are distributed with Metafont only in *.mf source form. But all the font sources are in the typical Metafont distribution.)
3. the texman.tex and read the Warning Message carefully.
4. Realize that you have to edit the source and that you need to run in debug mode to figure out what's going on.
5. Break out the warning loop by changing one boolean variable's value.
6. again to get the texman.dvi file.
7. Call 1-800-321-4AMS to order the Book from the AMS.
Weiqi Gao (weiqigao@crl.com) Tim Murphy asks if there is any restriction on ing the book.

Here is the relevant statement from the latest texbook.tex:

\loop\iftrue
\errmessage{This manual is copyrighted and should not be TeXed}\repeat

I think that's pretty clear.

There are a few specific conditions under which knuth has given explicit permission for the book to be ed:

• testing, by the implementor, of a new or updated implementation of
• timing tests of different implementations on the same machine by someone preparing a review for publication
in neither case is it necessary to print, or even to preview, the resulting dvi file. (validation of a new or updated implementation can be done by comparing the dvi file with another known to be valid.) For any other use, permission should be requested in writing from knuth, addison-wesley, and the american mathematical society.

bbeeton (BNB@MATH.AMS.ORG)

## Simple Guide to MetaFont

Donald Knuth, the author of Metafont, has written a nice (bright orange) book called "The METAFONT Book", published by Addison-Wesley.

Laurence Penney (Lorp@truetype.demon.co.uk)

On the other hand, it's difficult to use this book as a guide to so much as generate PK files for the CM fonts. There is at least one brief guide to MF on the net whose location has escaped me, but it's GOT to be on CTAN, at least.

Donald A. Hosek (quixote@Primenet.Com)

CTAN tex-archive/info/metafont-for-beginners.tex

Robin Fairbairns (rf@cl.cam.ac.uk)

To sumbmit something for installation on CTAN, you should ftp it (preferably as a .tar.gz or .zip file) to a CTAN /incoming directory, and send mail to ctan@shsu.edu saying:

• the name of the package
• which CTAN host you uploaded to
• an outline the package's function
• a suggestion for its location on CTAN (if you have one)
One of us will do the rest...

Robin Fairbairns (rf@cl.cam.ac.uk)

# Local stuff

The following articles appear only in danish. Anyway they are local to the Department of Computer Science at The University of Copenhagen (DIKU), so it will be of interest only for people understanding danish.

## Sådan genereres fonte

Fonte genereres vha. MakeTeXPK, der har følgende syntaks:
MakeTeXPK navn dpi bdpi skalering [mode [destdir]]

hvor parametrene er følgende:
• navn: er fontens navn, f.eks. cmr10
• dpi: er den opløsning som fonten skal genereres til
• bdpi: er basis opløsning, bruges til at bestemme mode
• skalering: skalering (eng. magnitude) at fonte - en faktor, som fonten forstørres med på alle leder.
• mode: hvilken modus (dvs. udskrivningsenhed) fontene skal genereres til. Typisk cx.
• destdir hvor de genererede filer placers. Enten absolut (starter med /) eller relativt til den aktuelle placering (uden /)
Eksempelvis genererer

MakeTeXPK bbding10 300 300 1 cx ~/LaTeX/MFinput

fonten bbding10 (en symbolfont) til en udskriftsenhed med 300 DPI i en opløsning på 300DPI uden skalering. Fontene placeres i standardkatalogerne, hvilket er i orden for EDB-afdelingen. De kan dog gemmes andre steder vha. forskellige omgivelsesvariable.

Egen sammenfatning

Det meste af det følgende er for tiden totalt udokumenteret. Noget af det vil til sin tid komme til at stå i vores Local Guide til .

• MFINPUTS: Sæt den til ~/LaTeX/MFinput:'', så METAFONT også kan finde diverse hjælpefiler. (Det tomme element (efter :) står for standard-søgestien).
• Autogenerering af TFM-filer: setenv USE_MAKETEXTFM'' vil få og til at prøve og generere TFM-filer hvis de mangler.
• Autogenerering af PK-filer i xdvi: brug +maketexpk.
• Privat katalog til autogenererede filer: sæt omgivelsesvariablen MTP_DESTDIR'' til et katalognavn af formen ~/.../pk''. Så vil PK-filer ende i ~/.../pk/<mode>, hvor <mode> afhænger af printeren, og TFM- filer vil ende i ~/.../tfm. For at , xdvi og dvips skal kunne finde filerne igen uden at køre MakeTeXPK, skal man sætte
TFMFONTS=~/.../tfm:
PKFONTS=~/.../pk//:

Men dette er ikke noget som man behøver at lære, hvis man ikke synes det er sjovt. Den grundlæggende antagelse, at man ikke må lægge uddata fra egne MF-filer op i /usr/local/lib/texmf/fonts/tmp, er nemlig ikke korrekt. Vi regner ikke med at folk kan bruge så mange forskellige skrifter og størrelser at der bliver problemer med pladsen, og hvis de gør, så laver vi et script til at fjerne filer der ikke bliver brugt.

Lars Mathiesen(thorinn@diku.dk)

danieldf@latt.if.usp.br, June 25, 1999.
You're not the only one visiting this page. There has been since June 25, 1999.