TeXnical notes

From stacky wiki

Sometimes I find a solution to a TeXnical problem, and I think everybody should know about it. Some of these things are totally obvious, but (as far as I know) non-standard.

You may also want to check out my advice on real-time TeXing.

BibTeX without a separate .bib file

dvi tex

$Bib\TeX$ has the nice feature that it makes your bibliography nicely; the entries are all formatted the same way, and it is easy to change that format. However, it is annoying that you have to have a separate .bib file to contain all your bibliography entries. Fortunately, it is not too hard to build the .bib file into the .tex file. To illustrate, the source of [Ant06] is (sorta) included below. Note that you have to run $\LaTeX$, $Bib\TeX$, $\LaTeX$, $\LaTeX$, as usual when you use $Bib\TeX$.

\documentclass{article}
\usepackage{verbatim}
\begin{document}
Bib\TeX\ has the nice feature that it makes your bibliography
nicely; the entries are all formatted the same way, and it is
easy to change that format. However, it is annoying that you
have to have a separate \verb|.bib| file to contain all your
bibliography entries. Fortunately, it is not too hard to build
the \verb|.bib| file into the \verb|.tex| file. To illustrate,
the source of \cite{this_file} is (sorta) included below.
Note that you have to run \LaTeX, Bib\TeX, \LaTeX, \LaTeX, as
usual when you use Bib\TeX.

   %%%%%%%%%%%%%%%%%%%%%%%%%%%
   %%% main text goes here %%%
   %%%%%%%%%%%%%%%%%%%%%%%%%%%

 \bibliography{\jobname}
 \bibliographystyle{alpha}

 \openout0= \jobname.bib
 \write0{
   @book {this_file,
       AUTHOR = {Anton},
        TITLE = {This document},
         YEAR = {2006},
   }
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %%% more bib entries go here %%%
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 }
\end{document}

References
[Ant06] Anton. This document. 2006.

How to draw the Fox-Artin wild arc with pstricks

\documentclass{article}
\usepackage{pstricks}
\usepackage{multido}
\begin{document}
 \[\begin{pspicture}(-7.6,-.5)(7.32,2.5)
    \newdimen\totaljump     % This measures where the orgin is
    \newdimen\jumpinterval  % This measures how much the origin moves each time
    %%%%% First we draw the left hand side. Because we are utilizing borders, we have %%%%%
    %%%%% to draw from left to right, so compute by hand what the unit should be.     %%%%%
    \psset{unit=0.17293822569mm,border=.05,linewidth=.03}
    \totaljump=-75mm
    \jumpinterval=0.17293822569mm
    \multido{}{20}{
      % Move the origin to the appropriate place %%%%
      \psset{origin={\totaljump,0}, unit= 1.25, border=.05, linewidth=.03}
      % Draw a piece of the curve
      \pscurve(-.1,.1)(-.2,.3)(0,1.5)(1,.7)(2.3,.3)(2,-.05)(1.1,-.2)(1,-.1)
      % Scale the jumpinterval by .8 and increment totaljump
      \multiply\jumpinterval by 5 \divide\jumpinterval by 4
      \advance\totaljump by \jumpinterval
    }
    %%%% Now we draw one piece of the curve in the middle %%%%
    %%%% to get the two ends to match up nicely.          %%%%
    \psset{unit=1.5cm,border=.05,linewidth=.03}
    \pscurve(-.15,.12)(-.2,.3)(0,1.7)(1,.7)(1.8,.3)(1.6,-.05)(1.1,-.2)(.95,-.15)
    %%%% Now draw the right hand side %%%%
    \psset{origin={12mm,0}}
    \totaljump=12mm
    \jumpinterval=12mm
    \multido{}{20}{
      \advance\totaljump by \jumpinterval
      \multiply\jumpinterval by 4 \divide\jumpinterval by 5
      \pscurve(-.1,.1)(-.2,.3)(0,1.5)(1,.7)(1.6,.3)(1.4,-.05)(1.1,-.2)(.9,-.1)
      \psset{origin={\totaljump,0}, unit= .8, border=.05, linewidth=.03}
    }
 \end{pspicture}\]
\end{document}

Placing labels on arrows in XY-pic

(I learned this trick from Aaron Lauda; I haven't seen it documented anywhere)

\xymatrix{asdfasdf \ar[r]^{f} & a }

produces the label "f" in a stupid place, half-way between the centers of the two entries, instead of where you'd like it to be, half-way along the arrow. One way to handle this is to do something like \ar[r]^(.7){f} but that is fairly unsatisfying because you have to calibrate the (.7) by eye. There is another way, which is to use

\ar[r]^-{f}

which will automatically place the label "f" half-way along the arrow. If you want the label .7 of the way along the arrow, you can do \ar[r]^-(.7){f}.

[Todo: should really add some stuff about \show here]