Tuesday, 22-Dec-2015 14:11:51 EST

TEX

Some math macros

Here are a few of the definitions I made for some useful math stuff. (For more, see some of my recent papers; at least the ones I typed.)
% accent over:
\def\on#1#2{{\buildrel{\mkern2.5mu#1\mkern-2.5mu}\over{#2}}}
\def\oonoo#1#2#3{\vbox{\ialign{##\crcr
	\hfil\hfil\hfil{$#3{#1}$}\hfil\crcr\noalign{\kern1pt\nointerlineskip}
	$#3{#2}$\crcr}}}
\def\oon#1#2{\mathchoice{\oonoo{#1}{#2}{\displaystyle}}
	{\oonoo{#1}{#2}{\textstyle}}{\oonoo{#1}{#2}{\scriptstyle}}
	{\oonoo{#1}{#2}{\scriptscriptstyle}}}
% accent under:
\def\under#1#2{\mathop{\null#2}\limits_{#1}}
% dot:
\def\dt#1{\oon{\hbox{\bf .}}{#1}}  
% double dot:
\def\ddt#1{\oon{\hbox{\bf .\kern-1pt.}}#1}
% slash:
\def\slap#1#2{\setbox0=\hbox{$#1{#2}$}
	#2\kern-\wd0{\hfuzz=1pt\hbox to\wd0{\hfil$#1{/}$\hfil}}}
\def\sla#1{\mathpalette\slap{#1}}

Pdf(La)TEX

PdfTeX is more convenient than TeX, since it creates PDF directly from the source, rather than first creating DVI, then converting it to PS with Dvips, and finally converting PS to PDF with Ghostscript.

However, PdfTex can use figures as anything but PS or EPS, while ordinary TeX can use only PS or EPS. (You really would want EPS instead of PS anyway, for figures with bounding boxes as opposed to full pages.) But PdfLaTeX will automatically convert EPS to PDF if you use graphicx (see below).

Even arXiv.org now accepts submissions as PdfLaTeX (but not yet plain PdfTeX).

Slides

There are many fancy ways to do presentations, with or without TeX. If you want to be simplistic, you can do it in pdfLaTeX without special packages with just a few lines:
\documentclass[12pt]{article}
% for landscape
\pdfpagewidth=11in \pdfpageheight=8.5in
\textwidth=10in	\textheight=7.5in
\topmargin=-1in
\oddsidemargin=-.5in \evensidemargin=-.5in
\parindent=0in
% so people won't keep asking, "How much more do you have?" e.g., for 11 slides
\setcounter{page}{-10}
\begin{document}
% big, bold, san serif
\Huge\sffamily\bfseries\boldmath

Figures

If you want math/text alongside a figure, put it all in an equation, and put the figure command inside \vcenter{\hbox{...}}.

To include graphics files, you can use the graphicx package:

Use commands like \includegraphics[width=1.5in]{foo}.

Alternatively, for plain TeX you can use epsf (but pdftex doesn't need it) by adding just a few macros, e.g., something like

%
% for ordinary tex
%
\ifx\pdfoutput\undefined
\input epsf
\def\fig#1{\epsfbox{#1.eps}}
\def\figscale#1#2{\epsfxsize=#2\epsfbox{#1.eps}}
%
% for pdftex
%
\else
\def\fig#1{\pdfximage {#1.pdf}\pdfrefximage\pdflastximage}
\def\figscale#1#2{\pdfximage width#2 {#1.pdf}\pdfrefximage\pdflastximage}
\fi

Hyperref

Arxiv.org now uses hyperref (the standard macro package in LaTeX for adding web links, especially for PDF) by default. Default preferences may change with the version of hyperref, so you may want to set your own. I don't use LaTeX, but some of my collaborators do, so here is how I used hyperref: I began the document with
\documentclass[12pt]{article}
% bookmarks, links, colors:

\usepackage{hyperref}
\hypersetup{bookmarksopen,bookmarksnumbered,pdfstartview=FitH,colorlinks,citecolor=blue,unicode}
\def\hhref#1{\href{http://arxiv.org/abs/#1}{arXiv:#1}} % in bibliography
\def\mhref#1{\href{mailto:#1}{#1}}		% email on title page
The options are: \hhref is for the bibliography (just put the arXiv number as argument), and \mhref is for the title page (your email address as argument).

Hyperref gives extra error messages when used with pdflatex. E.g., an error message like

! pdfTeX warning (ext4): destination with the same identifier (name{equation.4.
2.12}) has been already used, duplicate ignored
 
                   \endgroup \set@typeset@protect 
l.739 \end{eqnarray}
will occur if you use \nonumber on every line of an equation. You should use, e.g., eqnarray* instead.

BibTEX

Whereas non-standard tex inputs need to be put somewhere in ~/Library/texmf/tex/, bibtex .bst files need to go in ~/Library/texmf/bibtex/bst/.

To avoid doing pdflatex, bibtex, pdflatex, pdflatex, move the latexmk engine from ~/Library/TeXShop/Engines/Inactive/Latexmk/ to .../Engines/. The only menu item it will appear in is the Program list in the source window bar (so you'll need that button as well as the Typeset one).

Miscellaneous LaTeX stuff

For citations like [1-10] & not [1,2,3,4,5,6,7,8,9,10], \usepackage{cite} .

To get colors on OS X the same (as bright as) on iOS, \usepackage[rgb]{xcolor} .

To get equations numbered by subsection,

\catcode`@=11
\@addtoreset{equation}{section}
\catcode`@=12
\numberwithin{equation}{subsection}
or just \numberwithin{equation}{section} for section.

PDF: bookmarks, links, colors

I use plain TeX, so I wrote my own macros (mostly pieced together from other people's stuff). They worked for me, but they are not guaranteed, so use at your own risk (of doing extra work). Here is a recent version (used since the second edition of Fields):

% postscript/pdf

\newcount\marknumber	\marknumber=1
\newcount\countdp \newcount\countwd \newcount\countht 

%
% for ordinary tex
%
\ifx\pdfoutput\undefined
\def\rgboo#1{\special{color rgb #1}}
\input epsf
\def\fig#1{\epsfbox{#1.eps}}
\def\figscale#1#2{\epsfxsize=#2\epsfbox{#1.eps}}
\def\postscript#1{\special{" #1}}		% for dvips
\postscript{
	/bd {bind def} bind def
	/fsd {findfont exch scalefont def} bd
	/sms {setfont moveto show} bd
	/ms {moveto show} bd
	/pdfmark where		% printers ignore pdfmarks
	{pop} {userdict /pdfmark /cleartomark load put} ifelse
	[ /PageMode /UseOutlines		% bookmark window open
	/DOCVIEW pdfmark}
\def\bookmark#1#2{\postscript{		% #1=subheadings (if not 0)
	[ /Dest /MyDest\the\marknumber /View [ /XYZ null null null ] /DEST pdfmark
	[ /Title (#2) /Count #1 /Dest /MyDest\the\marknumber /OUT pdfmark}%
	\advance\marknumber by1}
\def\pdfklink#1#2{%
	\hskip-.25em\setbox0=\hbox{#1}%
		\countdp=\dp0 \countwd=\wd0 \countht=\ht0%
		\divide\countdp by65536 \divide\countwd by65536%
			\divide\countht by65536%
		\advance\countdp by1 \advance\countwd by1%
			\advance\countht by1%
		\def\linkdp{\the\countdp} \def\linkwd{\the\countwd}%
			\def\linkht{\the\countht}%
	\postscript{
		[ /Rect [ -1.5 -\linkdp.0 0\linkwd.0 0\linkht.5 ] 
		/Border [ 0 0 0 ]
		/Action << /Subtype /URI /URI (#2) >>
		/Subtype /Link
		/ANN pdfmark}{\rgb{1 0 0}{#1}}}
%
% for pdftex
%
\else
\def\rgboo#1{\pdfliteral{#1 rg #1 RG}}
\def\fig#1{\pdfximage {#1.pdf}\pdfrefximage\pdflastximage}
\def\figscale#1#2{\pdfximage width#2 {#1.pdf}\pdfrefximage\pdflastximage}
\pdfcatalog{/PageMode /UseOutlines}		% bookmark window open
\def\bookmark#1#2{
	\pdfdest num \marknumber xyz
	\pdfoutline goto num \marknumber count #1 {#2}
	\advance\marknumber by1}
\def\pdfklink#1#2{%
	\noindent\pdfstartlink user
		{/Subtype /Link
		/Border [ 0 0 0 ]
		/A << /S /URI /URI (#2) >>}{\rgb{1 0 0}{#1}}%
	\pdfendlink}
\fi

\def\rgbo#1#2{\rgboo{#1}#2\rgboo{0 0 0}}
\def\rgb#1#2{\mark{#1}\rgbo{#1}{#2}\mark{0 0 0}}
\def\pdflink#1{\pdfklink{#1}{#1}}
\def\xxxlink#1{\pdfklink{#1}{http://arXiv.org/abs/#1}}
There is more, but much more than you want to see (and much more than I want to explain), because I colorized everything, including page headers, chapter/section headings, and exercises (which sometimes ran to the next page, and hence were interrupted by page headers). The \rgb... macros are for colorizing (and remembering the color as a \mark); the \...link macros are for web links; the \bookmark macro is for a bookmark (with the first argument the number of subheadings).

Local stuff

Long ago I modified letter.sty of LaTeχ 2.09 to use the Stony Brook logo & letterhead. (Sorry, I haven't updated it to LaTeχ 2ε yet. Doesn't everybody use email anyway?) So here are template.tex, newletter.sty, & shieldlogo.pdf. (As usual, for TeXShop, put them somewhere in Library/texmf/tex.)

You may also want the shield by itself for other purposes, so here's shield.pdf.