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

Collected by Peter Møller Neergaard

This page contains various questions and answers about TeX and LaTeX, 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!


Contents:


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

\def\mathbox#1{\hbox{$\mathpalette\@mathbox{#1}}}
\def\@mathbox#1#2{#1#2}

\def\braket#1#2{%
  \setbox0 = \mathbox{#1} \@tempdima=\ht0 \@tempdimb=\dp0
  \setbox0 = \mathbox{#2} \@tempdimc=\ht0 \@tempdimd=\dp0
  \ifdim \@tempdimc > \@tempdima
    \@tempdima = \@tempdimc
  \fi
  \ifdim \@tempdimd > \@tempdimc
    \@tempdimb = \@tempdimd
  \fi
  \def\@tempa{\vrule width0pt height\@tempdima depth\@tempdimb}
  \left.\left\langle\@tempa{#1}\,\right|\,{#2}\right\rangle}
Colin James Wynne

Four dot ellipses

A few days ago somebody was asking how to achieve a good-looking four-dot ellipsis, for use when a quoted sentence is truncated (as opposed to the three-dot ellipsis when material is left out of the middle of a sentence).

I too have noticed that \dots plus a period produces irregular and unsightly spacing. Here's a solution: define a four-dot ellipsis on the same pattern as \dots, thus --

\def\ldotsplus{\mathinner{\ldotp\ldotp\ldotp\ldotp}}
\def\fourdots{\relax\ifmmode\ldotsplus\else$\m@th \ldotsplus\,$\fi}
Then you can type \fourdots\ That made a proper sentence-ending ellipsis. (Or you could type $\ldotsplus$ for the same effect.) Just stick the above two definitions into the style file you are using, or make a separate style file of them.

Allin Cottrell (cottrell@wfu.edu)


Larger Parenthesis

I want the outer parenthesis larger than the inner parenthesis.

\bigl((x+b)\bigr)

Most people who ask for this are trying to use \left and \right.

First, the problem with \bigl and \bigr is (or was) that they just copy the plain TeX definition, for 10pt, and don't change size to match the document. Moreover, LaTeX, by default, uses the same font for big parentheses at all sizes. The upshot is that in a 12pt document, \big is the same size as an ordinary parenthesis!

The solution; \usepackage{exscale} to scale the math extensions properly, and get a sty file that redefines \big etc to be sensitive to the font size. I forget which package does this...but it should probably go into exscale.

Alternatively, use exscale, but set \delimitershortfall=-2pt and then type $\left((x+b)\right)$

Donald Arseneau (asnd@reg.triumf.ca)


Setting Margins

I find the LaTeX method of setting margins/textwidth somewhat counter-intuitive. Perhaps I this is because I was corrupted by Microsoft Word at a young age. The following lines allow the user to specify the top/left/top/bottom margins and LaTeX calculates the rest. Note that it requires the calc package.
 %%% Begin Example

\newlength{\myrightmargin}
\newlength{\myleftmargin}
\newlength{\mytopmargin}
\newlength{\mybottommargin}

% Change these settings to change the margins
\setlength{\myrightmargin}{1.0in}
\setlength{\myleftmargin}{1.0in}
\setlength{\mytopmargin}{1.0in}     
\setlength{\mybottommargin}{1.0in} 
\setlength{\oddsidemargin}{0.0in}   % extra room on inside side

%%% use margin settings to set width variables
\setlength{\evensidemargin}{0 in}
\setlength{\marginparsep}{0 in}
\setlength{\marginparwidth}{0 in}
\setlength{\hoffset}{\myleftmargin - 1.0in}
\setlength{\textwidth}
  {8.5in -\myleftmargin -\myrightmargin -\oddsidemargin}

%%% use margin settings to set height variables
\setlength{\voffset}{\mytopmargin -1.0in}
\setlength{\topmargin}{0 in}
\setlength{\headheight}{12 pt}
\setlength{\headsep}{20 pt}
\setlength{\footskip}{36 pt}
\setlength{\textheight}
  {11.0in-\mytopmargin-\mybottommargin-\headheight-\headsep-\footskip}
Hope this helps,

Keith Reckdahl (reckdahl@leland.stanford.edu)


Ragrighting a hole document

I have a document that I want to format entirely with a ragged right margin. My first attempt was to include \raggedright at the top of the document, however with \raggedright LaTeX does not hyphenate at all and the lines come out much too ragged.

A full solution is the following LaTeX2e-style file:

\makeatletter

% LaTeX \raggedright turns off hyphenation somehow.

\rightskip=0pt plus2em
\spaceskip=.3333em plus.03em minus .02em
\xspaceskip=.5em plus.08em minus.02em
\@rightskip=\rightskip % for LaTeX


%\hbadness=10000

% This is supposed to prevent very long words from sticking out into the
% right margin.  Instead they will be moved into the next line.
\emergencystretch=\hsize
\tolerance=9999

\def\@arrayparboxrestore{%
  \let\par\@@par
  \let\-\@dischyph
  \let\'\@acci\let\`\@accii\let\=\@acciii
  \parindent\z@ \parskip\z@skip
  \everypar{}%
  \linewidth\hsize
  \@totalleftmargin\z@ 
  \leftskip\z@skip \rightskip\@rightskip
  \parfillskip\@flushglue \lineskip\normallineskip
  \baselineskip\normalbaselineskip
  \sloppy}
David Hull (hull@cs.uiuc.edu) (Changed on advise from David Hull, ed.)

More than nine marginal notes on a page

John McMillan (phy6jem@sun.leeds.ac.uk) wrote:
David Gast (gast@twinsun.com)wrote:
If I ever try to put more than 9 marginal notes on a page, I get an error message like
   ! LaTeX Error: Too many unprocessed floats.
I was unsuccessful in avoiding this problem by setting values like \totalnumber.

Is there some way to permit more than nine marginal notes?

Indeed; the limit is indeed that of the number of unprocessed floats (instantaneously) permitted. Maybe David already has unprocessed floats lying around.

While searching for something else recently, I came across a reference to a package called morefloats.sty which claims to address this problem. I haven't found it yet let alone downloaded it and tested it. I guess its in CTAN somewhere and may or may not work with LaTeX2e.
It's in macros/latex209/contrib/misc/morefloats.sty and it does work with 2e. It's kind of sledgehammer code, but it does the job.

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


How to Put Float And Caption on a Separate Page

Try:
text text text ...
\begin{figure}[p] ... \caption{...}\end{figure}
\clearpage
Guido Sawade (sawade@physik.tu-berlin.de)
Use the `afterpage' package that follows with the LaTeX2e tools.

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

Using ASCII 0-31 in LaTeX

I have a LaTeX2.09 compatible style file which uses the ``^^'' symbol. This is not understood by LaTeX2e at all (illegal character), and I don't know how it worked or what it was meant to do originally.
In fact you missed out the important bit (which the charcter was) the usage of ^^ (a primitive TeX feature, not a LaTeX feature) is either folled by a single character eg ^^A this means control-A ie a character 64 away from A in the ASCII table or two lower case hex digits 0-91-f ^^ab The character of code hex ab (ie 16*10+11)

Most likely the ^^ notation was refering to a chaacter of code less than 32, which are `illegal' in LaTeX as they do not work on all TeX systems. However if you just want to make them legal again to get your package working go

\catcode`\^^A=12
\catcode`\^^B=12
(with whatever characters you need instead of ^^A, ^^B) before loading in the package.

David Carlisle (carlisle@ma.man.ac.uk)


Non italicised Greek characters

M.Simpson (byx015@coventry.ac.uk) wrote:
How do you get non-italicised Greek lower case characters in LaTeX? Using \mathrm seems only to change capitals. I particularly need to get \mu for units such as microamps.
Here is a short example, assuming you have fetched and installed the greek fonts in ftp://ftp.tex.ac.uk/tex-archive/fonts/greek/kelly
\documentclass[a4paper]{article}
\DeclareFontShape{OT1}{cmg}{m}{n}{<-> cmg10}{}
\DeclareFontFamily{OT1}{cmg}{}
\newcommand{\MU}{{\fontfamily{cmg}\fontseries{m}%
   \fontshape{n}\selectfont m}}
\begin{document}
 \MU
\end{document}
Mike Piff (M.Piff@shef.ac.uk)

Upright Letters in Math

Maarten D de Jong (dejong@cpt6.stm.tudelft.nl) wrote:
I am trying to substitute the italics in formulas for upright letters, but without the need for typing \mathrm{. . .} inside the formula all the time. In other words, I want to change the default font from italic to normal.

The only thing that worked sofar was

\SetSymbolFont{letters}{normal}{OT1}{cmr}{m}{n}
As it is the wrong encoding, you will run into trouble (greek letters and other symbols). I would suggest to change only the letters you want to change.

\DeclareSymbolFont{pletters}{OT1}{panr}{m}{it}
\SetSymbolFont{pletters}{bold}{OT1}{panr}{m}{it}
\DeclareSymbolFont{operators}{OT1}{panr}{m}{n}
\SetSymbolFont{operators}{bold}{OT1}{panr}{bx}{n}

\DeclareMathsymbol{a}{\mathalpha}{pletters}{`a}
\DeclareMathsymbol{b}{\mathalpha}{pletters}{`b}
\DeclareMathsymbol{c}{\mathalpha}{pletters}{`c}
\DeclareMathsymbol{d}{\mathalpha}{pletters}{`d}
Vincent Zoonekynd (zoonek@DPTMaths.ENS-Cachan.Fr)

What are the TC fonts?

They are Text Companion fonts. They are supposed to contain non-mathematical symbols for use in text. They are inside fontdc.zip because they are part or the dc fonts distribution.

Dan Luecking (luecking@comp.uark.edu)


Fonts at Great Magsteps

I am having trouble using cmb10 scaled at magstep8. Can anyone help? When I access it in Plain TeX however:
\font\bigfont= cmb10 scaled \magstep8
\bigfont{test of Bigfont}
TeX complains:
! Missing number, treated as zero0.

            \relax
l.5 \font\bigfont= cmb10 scaled \magstep8
Try `MagSteps.TeX': It allows dynamic re-creation of the \magstep macro for any number of magsteps limited only by TeX's integer capabilities. Usage is `\magsteps n', for integer n, followed by (optional) usage of the so-created \magstep command.
\catcode `\@ = 11

\newcount \r@mainder
\newcount \m@gstepcount
\newcount \m@gsteplimit
\newcount \m@gstepvalue
\newdimen \m@gstepdimen

\def \magsteps {\afterassignment \m@gsteps \m@gsteplimit = }

\def \m@gsteps
    {\let \@r = \or
     \def \or {\noexpand \or}%
     \m@gstepdimen = 0.166667 \maxdimen
     \m@gstepvalue = 1000 
     \m@gstepcount = 0
     \def \magstep {}%
     \loop
     \ifnum \m@gstepcount < \m@gsteplimit
            \advance \m@gstepcount by 1
            \ifnum \m@gstepvalue > \m@gstepdimen
                   \advance \m@gstepcount by -1
                   \message {Sorry --- integer overflow would occur if
                             I went any further; stopped at 
                             \the \m@gstepcount.}
                   \m@gsteplimit = \m@gstepcount 
            \else
                   \multiply \m@gstepvalue by 12
                   \multiply \r@mainder by 12
                   \divide \r@mainder by 10
                   \advance \m@gstepvalue by \r@mainder
                   \r@mainder = \m@gstepvalue
                   \divide \m@gstepvalue by 10
                   \multiply \m@gstepvalue by 10
                   \advance \r@mainder by -\m@gstepvalue
                   \divide \m@gstepvalue by 10
                   \ifnum \r@mainder < 5
                     \edef \magstep {\magstep \or \the \m@gstepvalue}%
                   \else
                     \advance \m@gstepvalue by 1
                     \edef \magstep {\magstep \or \the \m@gstepvalue}%
                     \advance \m@gstepvalue by -1
                   \fi
            \fi
     \repeat
     \edef \magstep ##1%
          {\noexpand \ifcase ##1
                        1000\magstep 
           \noexpand \else 0%
           \noexpand \message 
                {Sorry --- \string \magstep \space ##1
                 is not in range 0 .. \the \m@gsteplimit}%
           \noexpand \fi
           \noexpand \relax
          }%
     \let \or = \@r
    }

\catcode `\@ = 12
Philip Taylor (CHAA006@alpha1.rhbnc.ac.uk)

Real HUGE fonts

Wonkoo Kim (wkim+@pitt.edu) writes:
\newcommand{\HUGE}{\fontsize{35}{45}\selectfont}
This gave me a problem. cm fonts are substuted by 24.88pt if I tried any bigger fonts, and it didn't work with some other fonts. Any further help? (I'm using emTeX under OS/2.)
The fonts you use must be specified in OT1cmr.fd. This is presumably to stop an inordinately large collection of fonts being made.

Note that you can overrule the command in your own file, as eg by copying this from OT1cmr.fd to your LaTeX file

\DeclareFontShape{OT1}{cmr}{m}{n}
   {  <5> <6> <7> <8> <9> <10> <12> gen * cmr
      <10.95> cmr10
      <14.4>  cmr12
      <17.28><20.74><24.88>cmr17}{}
and changing the last line (in your file) to
      <17.28><20.74><24.88><35>cmr17}{}
or to
      <17.28><20.74><24.88->cmr17}{}
(This allows any size larger than 24.88).

Timothy Murphy (tim@maths.tcd.ie)


Where to ask questions about METAFONT

In principle, this group (comp.text.tex, ed.) is supposed to cover metafont, but I know that a lot of high-power metafonters don't read it.

Try subscribing to the metafont list. I wrote in the UKTUG FAQ:

Issues related to Metafont (and, increasingly, MetaPost) are discussed on the metafont mailing list; subscribe by sending a message `subscribe metafont your name' to listserv@ens.fr
Robin Fairbairns (rf@cl.cam.ac.uk)

Detecting two following tokens

Young U . Ryu (ryoung@utdallas.edu) writes
Then, is there any way that achieves the following imaginary command: \futurefutureletCS-a CS-b TK1 TK2 TK3 performs \letCS-a=TK2, performs \letCS-b=TK3, processes TK1, processes TK2, and then processes TK3.
In the special case where TK1 is a CS (more generally, whenever the token can act as a parameter), the solution is easy:

\def\futurefuturelet#1#2#3{\def\tempmacro{\afterassignment#3%
                           \futurelet#2}\futurelet#1\tempmacro}%
I haven't actually checked this, but barring typos it should work (unless CS-a is the name \tempmacro, or TK1 is the name \tempmacro and CS-b is not :-)

Tanmoy Bhattacharya (tanmoy@qcd.lanl.gov)


One of the main uses for \futurelet is to detect a following "{". In many contexts, reading in a brace and putting it back is not going to work. \futurelet can also be used at the end of a macro (without knowing what either TK1 or TK2 is), but this use seems to be rare. Therefore the following can frequently replace \futurelet, but will not be applicable in all cases.

One can emulate \futurelet, when TK1 is a command, by the following: \afterassignmentTK1\letCS TK2 , provided TK1 does the job of processing TK2 (or rather, the CS that has been \let equal to TK2.

This type of thing can be extended to more than one following token by having TK1 perform another such operation or a \futurelet:

\def\X{\afterassignment\getsecond\let\first=}
  \def\getsecond{\futurelet\second\processboth}
  \def\processboth{%
     ...             % code to examine \first and \second,
     ...             % perform some actions and then...
     \first          % put \first back
  }
This would be used like \XTK2 TK3 and produces the following order of execution:

This fails to work in those contexts where a control sequence \let equal to a token is different than the token itself. For instance, if one wishes to check some following token to see if a brace delimited macro parameter follows. \let-ing some CS equal to that brace and then putting the CS back will not work because TeX requires an explicit "{" (otherwise the single CS is interpreted as the entire parameter, without braces).

Dan Luecking (luecking@comp.uark.edu)


How to write commands to a file

A verbatim environment could be tricky (though not entirely impossible). However, if all you're ever doing is to transmit robust commands such as \bf, you can achieve the required effect by

\test{Hi \bf World}   =>   \let\protect\noexpand
                           \write\somefile{#1}
This is easy enough, but note that if you're using 2.09, \bf will then get transmuted to \pbf, which may or may not be acceptable.

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


Nothing LaTeX specific about this solution, but how about placing your information in a token register and then writing the contents of the register.

\newtoks\argtoks
\def\test#1{\argtoks={#1}\immediate\write\somefile{\the\argtoks}}
The \immediate here is necessary lest the contents of \argtoks change before the \write occurs.

Anders Svensson (svensson@math.ubc.ca)


Using \jobname

Rob van Dijk writes:
I would like to include some conditional text, based on the name of the file that's being `TeXed'. I have tried the following:
\def\fname={somename}
if\jobname\fname\dothis\else\dothat\fi
However, the if-test is always false, even when the filename is `somename.tex'. ...
\if ....
expands the following tokens and tests the first two non-expandable tokens it finds, so it would return true if the first two letters of the filename were the same.

So you probably meant \ifx rather than \if \def\x{abc} \def\y{abc} then \ifx\x\y will be true.

However \jobname is a strange beast. It returns the letters with catcode 12 and as it is not a macro it is not \ifx equivalent to any macro. Thus you first have to make a macro with the letters you want to test all set to catcode 12 (I use \meaning and the LaTeX command \stip@prefix to generate this below) and then you need a second macro with the contents of \jobname. Then you can compare them with \ifx.

\makeatletter
\def\aaa{xx}\edef\aaa{\expandafter\strip@prefix\meaning\aaa}
\edef\bbb{\jobname}

\ifx\bbb\aaa
   \show\yes
\else
   \show\no
\fi
this will show \yes if the file name is xx and \no otherwise.

David Carlisle (carlisle@ma.man.ac.uk)


Michael Rolfe (mumble@maths.uct.ac.za) writes:
where \filename returns the name of the file containing the \if statement.
You will have to redefine \input:
\let\TeXinput\input
\def\input#1 {\edef\Temporary{\noexpand\TeXinput#1 
  \def\noexpand\filename{\filename}}%
  \def\filename{#1}\Temporary}
This restricts the \input syntax to ending filenames with a space; \relax or some such isn't allowed.

(I hope it works as typed.)

Donald Arseneau (asnd@reg.triumf.ca)


Roger de Reus (reus@PC2.MIC.DTU.DK) writes:
: \jobname returns the name of the file being processed,

This will give you the `name' part of the file (without path or extension). What is the hook for the full qualified file name?

I posted something like this to c.t.t some time back, I am not sure anyone would really want to use this (especially if they have a small disk quota:-)

but (if you know you are on a TeX that uses \jobname.log as the log file (ie not on VMS, where you have to make obvious change to .lis) you can get the full path from the log file. Unfortunately on Unix and presumably other systems writing to the file is buffered, so you have to write an awful lot of rubbish to flush out the buffer so the log really appears in the file, then you can read in the file and look at the first lines...

The code below sets the path to the path reported by TeX. If the file is in the current directory this may end up being just the filename like \jobname. On web2c unix TeX at least you can force TeX to give the full path in the log file by explicitly putting the current directory at the front of the TeX input path.

Thus if you save the code below as jobpath.tex this seems to work on my machine at least...

vummath> TEXINPUTS=$PWD: tex jobpath
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{%
  \read\logfile to \jobpathname
  \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
% now read it
\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 TeXbook 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{(}%
    \count0=\ht0\advance\count0 by\dp0\count1\baselineskip
    \advance\count0 by-\ht1\advance\count0by\ht2
    \dimen1=.5ex\advance\count0by\dimen1\divide\count0 by\count1
   \advance\count0 by1\dimen0\wd0
    \advance\dimen0 by.75em\dimen1=\ht0\advance\dimen1 by-\ht1
    \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 LaTeX2.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{%
    \hbadness5000 \vbadness9999 \tolerance9999
    \totalcolumns=#1   \separation=#2   \let\xpar=\par
    \vskip\parskip
    \columnsleft=#1\relax
    \hbox to\hsize\bgroup
    \let\par\nextmulticolumnparallelparagraph
    \dimen0=#2\advance\hsize-\columnsleft\dimen0 \advance\hsize\dimen0
    \divide\hsize\columnsleft\relax
    \vtop\bgroup}
\def\nextmulticolumnparallelparagraph{%
    \egroup
    \advance\columnsleft-1
    \ifnum\columnsleft>0
        \hfil\vtop\bgroup
    \else
	\egroup
        \xpar\vskip\baselineskip\xpar
        \multicolumnparallelparagraphs\totalcolumns\separation
    \fi}

\def\endmulticolumnparallelparagraphs{%
    \egroup
    \advance\columnsleft-1
    \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 (LaTeX) 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 TeX 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)


Tricky Leaders

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

This is a very bad case. No leaders at all 26
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 
leaders at all ........................... 26
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]
  {#1 \leaderfill #2 \par\emph{#3} \hfill\hfill\par\smallskip}

\newenvironment{Myindex}[1]
  {\setlength\parindent{0pt}
   \setlength\rightskip{#1}
   \setlength\parfillskip{-#1}
   \renewcommand{\leaderfill}
     {\cleaders \hbox to 4pt {\hss.\hss}
                \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
Instead of:
The Phenomenon ............... 3
We can put a Sub-
title here
Todd Hivnor (hivnot@rpi.edu)

Format with preloaded packages

Bob Gordon (gordon@euclid.math.temple.edu) writes:
I use the xy-pic drawing package with emTeX. 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'' LaTeX. I cannot get it to work with LaTeX2e. 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'' LaTeX 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 emTeX 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 LaTeX 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 TeX-book

OK, here is the instruction for reproducing the TeXBook using the TeX 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 TeX.)
  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. TeX the texman.tex and read the Warning Message carefully.
  4. Realize that you have to edit the source and that you need to run TeX in debug mode to figure out what's going on.
  5. Break out the warning loop by changing one boolean variable's value.
  6. TeX again to get the texman.dvi file.
  7. Call 1-800-321-4AMS to order the TeXBook from the AMS.
Weiqi Gao (weiqigao@crl.com) Tim Murphy asks if there is any restriction on TeXing the TeXbook.

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 TeXbook to be TeXed:

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)


Uploading to CTAN

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:

One of us will do the rest...

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


Lars Mathiesen(thorinn@diku.dk)
turtle@diku.dk, February 12, 1996.