Friday, 17-Aug-2018 08:38:32 EDT

TEX

Unicode

Proofreading .tex files is easier if Greek & math characters already appear as such there. arXiv.org has recently indicated to me a possibility of reluctantly accepting XɘTeX or LuaTeχ files. If this is true I can stop dealing with these characters using extended ASCII in Mac OS Roman encoding & viewing with my own font, by instead replacing it with the more modern utf-8 (Unicode) & viewing with standard Unicode fonts. (This approach works on all platforms.) Utf-8 has 17×2¹⁶ characters, compared to the measly 2⁸-character extended ASCII, so this allows almost all math symbols, excluding super/subscripts (except for numerals & signs), to appear literally before processing. (If they change their minds, I guess they'll be stuck with just my pdf files.) So far it seems LuaLaTeχ is the most convenient for adding new characters: e.g., \catcode`§=13 \def §{\section}.

For (@ least) TeXShop on the Mac, the .tex source file would begin with (before \documentclass)

% !TEX program = lualatex
% !TEX encoding = UTF-8 Unicode
The 1st line is to automatically recognize the Teχ engine (to save you another button; you can also use "TS-program" instead of "program"): Move the lualatex engine from ~/Library/TeXShop/Engines/Inactive/LuaTeX/ to .../Engines/. The 2nd is for file encoding (if utf-8 isn't already your default). Don't forget to set Edit > Substitutions > Text Replacement (using settings in System Preferences > Keyboard > Text).

Also, LaTeχ packages have already been written to recognize Unicode math, not just foreign languages: E.g., such a LuaLaTeχ file might begin

\documentclass[12pt]{article}
\usepackage{amsmath}			% needed for align & subeqs; must load before unicode-math
\usepackage[math-style=ISO,colon=literal]{unicode-math}
%	\setmathfont{STIX Two Math}	% most characters; Times-like
%	\setmainfont{XITS}
%	\setsansfont{TEX Gyre Heros}
The unicode-math package is for recognizing (converting to Teχ) Unicode math. (math-style=ISO is an option to make capital Greek "italic". colon=literal keeps math colons like text colons.) The commented font commands would be for output in Times New Roman-like fonts, rather than the default Computer Modern-like fonts Latin Modern. (The Teχ standard Computer Modern fonts are not Unicode, although there are "Computer Modern Unicode" fonts. STIX Two Text has optical size 10, and so is less elegant than standard Times New Roman clones like XITS.)

Math accents, etc.

There is also the problem that Unicode has you type accents after the letter, while Teχ wants them before. (Consider, e.g., δ̇.) With LuaLaTeχ, you can solve the problem with a Lua script, which essentially solves the problem in math the way it's already solved in text. Include a file for that script, & input it with the line
\AtBeginDocument{\directlua{require("combining_preprocessor.lua")}}
Here are a few of the definitions I made for this: First, mostly to modify dots,
% accent over:
\def\on#1#2{{\buildrel{{\mkern2.5mu\raise-.1em\hbox{$\scriptstyle#1$}\mkern-2.5mu}}\over{#2}}}
\def\ron#1#2{{\buildrel{{\raise-.1em\hbox{$\scriptstyle#1$}}}\over{#2}}}	% for unitalicized
\def\dt#1{\on{\hbox{\bf .}}{#1}}						% (big) dot over: see  ̇  below  
\def\ddt#1{\on{\hbox{\bf .\kern-1pt.}}#1}					% double dot: see ¨ below
\def\under#1#2{\mathop{\null#2}\limits_{#1}}					% accent under
then to allow Unicode typing of various characters, those math accents, & others:
% otherwise undefined utf-8
\catcode`〈=13	\def 〈{\langle}		% Option-[
\catcode`〉=13	\def 〉{\rangle}		% Option-]
\catcode`❴=13	\def ❴{\{}			% Option-{
\catcode`❵=13	\def ❵{\}}			% Option-}
\catcode`√=13	\def √{\sqrt}			% Option-M
\catcode`§=13	\def §{\section}		% Option-i
\catcode`¶=13	\def ¶{\subsection}		% Option-I
% spaces
\catcode`⎵=13	\def ⎵{\nobreak\ }				% Option-0
\catcode`⸏=13	\def ⸏{\quad}					% Option-)
%\catcode`␣=13	\def ␣{\TextOrMath{\thinspace}{\,}}		% (open box)
\catcode`˽=13	\def ˽{\TextOrMath{\thinspace}{\,}}		% Option-space (modifier letter shelf)
% combining characters
\def\̂#1{\TextOrMath{#1̂}{\hat{#1}}}		% Option-6
\def\̌#1{\TextOrMath{#1̌}{\check{#1}}}		% Option-V
\def\̃#1{\TextOrMath{#1̃}{\tilde{#1}}}		% Option-n
\def\́#1{\TextOrMath{#1́}{\acute{#1}}}		% Option-~
\def\̀#1{\TextOrMath{#1̀}{\grave{#1}}}		% Option-`
\def\̇#1{\TextOrMath{#1̇}{\dt{#1}}}		% Option-;
\def\̈#1{\TextOrMath{#1̈}{\ddt{#1}}}		% Option-:
\def\̆#1{\TextOrMath{#1̆}{\breve{#1}}}
\def\̄#1{\TextOrMath{#1̄}{\bar{#1}}}		% Option--
\def\̊#1{\TextOrMath{#1̊}{\mathring{#1}}}		% Option-A
\def\⃗#1{\vec{#1}}				% Option-R
\def\⃡#1{\overleftrightarrow{#1}}			% Option-E
\def\⃖#1{\overleftarrow{#1}}			% Option-W
\def\̸#1{\slashed{#1}}				% Option-/
% with single character only
%\def\͞#1{\overline{#1}}				% (combining double macron)
\def\̅#1{\overline{#1}}				% Option-? (combining overline)
%\def\̱#1{\underline{#1}}			% (combining macron below)
\def\̲#1{\underline{#1}}				% Option-_ (combining lowline)
%\def\͡#1{\widehat{#1}}				% (combining double inverted breve)
\def\᷍#1{\widehat{#1}}				% Option-^ (combining double circumflex above)
\def\͠#1{\widetilde{#1}}				% Option-N
(The commented Option-characters are the way I type them with my keylayout: See my Unicode page for details.) Then α̇α̌ᾱα̃α̸... in the .tex source comes out that way in the pdf.

Hyperref

hyperref is the standard macro package in LaTeX for adding links, etc. Some useful options (with sample colors):
\usepackage{hyperref}
\hypersetup{
	bookmarksnumbered,		% (sub)section numbers in bookmarks
	unicode,			% use with \texorpdfstring
	colorlinks,			% avoid stupid boxes
	citecolor=[rgb]{.9,0,.5},	% \cite
	urlcolor=[rgb]{0,0,1},		% \href
	linkcolor=[rgb]{0,.7,0}		% \ref , toc
	}
unicode is for using the macro \texorpdfstring{ }{ } in (sub)section headings, for the few cases not already covered by unicode-math (or your macros), where the former argument is for the tex to make it appear in the usual way in the body (e.g., {\LARGE$\bigcirc$}\hskip-.2in{\normalsize$\ddot\smile$}) & the latter for code to make it appear as unicode in the bookmarks (e.g., 🙂).

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). Or begin the file with

%%!TEX program = latexmk
Similar remarks apply to lualatex & lualatexmk.

Miscellaneous LaTeX stuff

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

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.