(La)TeX

Date

November 22, 2020

1 DVI

The following is a summary of the Wikipedia page 1 .

The device independent file format (DVI) is the output file format of the TeX typesetting program. DVI files are typically used as input to a second program (called a DVI driver) which translates DVI files to graphical data.

A driver is a program for previewing DVI files on a user’s computer display. Drivers are also used by converters that convert DVI to popular page description languages (e.g. PostScript, PDF) for rendering (by, eg. Ghostscript) and printing.

  • DVI-to-PS converters

    • dvips is the de facto standard.

  • DVI-to-PDF converters

    • dvipdf is a thin wrapper around dvips and Ghostscript.

    • dvipdfm supports most of the newer special functions of the PDF format, including bookmarks, annotations, thumbnails, and dvips specials — a feature making possible the inclusion of Encapsulated PostScript (.eps) files like METAPOST output — as well inclusion of JPEG and PNG images; other features of dvipdfm include partial font embedding (reducing file size) and balancing the internal PDF document trees to speed up rendering of large documents. However, many of these features (except for the direct support for .eps files) are also present in pdfTeX, which typesets TeX directly to PDF.

    • dvipdfmx is an extended version of the dvipdfm to support multi-byte character encodings and CJK character sets for East Asian languages as its primary goal.

  • DVI-to-SVG converters:

    • dvisvgm is the only one included in CTAN and actively maintained as of 2014.

    • dvisvg

    • dvi2svg

DVI differs from PostScript and PDF in that it does not support any form of font embedding. For a DVI file to be printed or even properly previewed, the fonts it references must be already installed.

Like PDF, DVI uses a limited sort of termination guaranteed machine language with that is not a full, Turing-complete programming language like PostScript.

2 PostScript

From Wikipedia 2 , 3 :

PostScript (PS) is a page description language in the electronic publishing and desktop publishing business. It is a dynamically typed, concatenative programming language.

PDF has largely replaced PostScript as de facto standard for electronic document distribution. On high-end printers, PostScript processors remain common, and their use can dramatically reduce the CPU work involved in printing documents, transferring the work of rendering PostScript images from the computer to the printer.

Metafont can be embedded into PostScript.

A file format converter, eg. ps2pdf that is distributed with Ghostscript, converts PostScript to PDF or vice versa.

3 Encapsulated PostScript (EPS)

From Wikipedia 4 :

Encapsulated PostScript (EPS) is a Document Structuring Conventions–conforming (DSC) PostScript document format usable as a graphics file format that can be placed within another PostScript document and includes a low-resolution preview “encapsulated” within it.

An EPS file contains a BoundingBox DSC comment, describing the rectangle containing the image described by the EPS file. Applications, even if they are unable to directly render the PostScript inside, can use this information to lay out the page.

EPS, together with DSC’s Open Structuring Conventions, form the basis of early versions of the Adobe Illustrator Artwork file format.

4 Raster fonts

From Wikipedia 5 :

A raster font (more commonly, a bitmap font or a pixel font) is a font that stores each glyph as an array of pixels (that is, a bitmap). Raster fonts are simply collections of raster images (also more commonly called bitmap images) of glyphs.

In comparison, vector fonts (including, and sometimes standing as a synonym for outline fonts) use Bézier curves, drawing instructions and mathematical formulae to describe each glyph, which make the character outlines scalable to any size.

5 Metafont

From Wikipedia 3 :

Metafont is a description language used to define raster fonts. It is also the name of the interpreter that executes Metafont code, generating the bitmap fonts that can be embedded into some page description languages, eg. PostScript.

One of the characteristics of Metafont is that the points defining the shapes of the glyphs are defined with geometrical equations.

Another characteristic is that Metafont is a macro language, where operations such as “draw a lower case top of stem serif at point 4” might appear as one macro instruction (with the point as argument) in the program for a letter.

Many families of Metafont fonts are set up so that the main source file for a font only defines a small number of design parameters (x-height, em width, slant, vertical stroke width, etc.), then calling a separate source file common for a whole range of fonts to actually draw the individual glyphs — this is the meta aspect of the system.

6 Ghostscript

From Wikipedia 6 :

Ghostscript is a suite of software based on an interpreter for PostScript (PS) and Portable Document Format (PDF) page description languages – as it takes the form of a language interpreter, it can also be used as a general purpose programming environment.

Its main purposes are the rasterization or rendering of such page description language files, for the display or printing of document pages, and the conversion between PostScript and PDF files. It can also serve as the back-end for PDF to raster image converters (to, eg., png, tiff, jpeg, etc.)

The ps2pdf conversion program comes with the ghostscript distribution.

7 Raster image converters

As mentioned in § Ghostscript, rater image converters convert PostScript or PDF to raster images. Those include ps2gif, ps2png, ps2tiff, ps2tiff, etc.

8 Image file formats, compared

Sources of the following summary include 7 , 8

  • GIF (Graphics Interchange Format) is an old low-color image format, common on the web. It is suitable for simple graphics such as drawings, logos, icons, graphics with flat colors and graphics without gradients. A GIF can be animated and used for simple animations. Lossless. Can represent max 256 colors.

  • PNG (Portable Network Graphics) is another common web format with features such as compression ratio (except for photos) and transparency. But it cannot be animated. Great for icons. Lossless. Can represent max 256 colors (PNG-8) or unlimited colors (PNG-24).

  • JPEG (Joint Photographic Experts Group) is the common format for photos. Its lossy compression algorithm is suited for squeezing photos to small files. Good for still images and photography. Can represent millions of colors. millions of colors.

  • TIFF (Tagged Image File Format) is a versatile image format. It has the ability to store multiple images, such as the pages of a scanned or faxed document.

  • SVG is good for graphics for high-dpi displays. vector and lossless. unlimited colors.

    • DVI-to-SVG converters 1 :

      • dvisvgm is the only one included in CTAN and actively maintained as of 2014.

      • dvisvg

      • dvi2svg

9 XQuartz

  • tlgmr -gui TeX Live Manager

  • texdoctk TeX Documentation Browser

10 Add section number to the pdf bookmark (outline) generated by hyperref package

\hypersetup{bookmarksnumbered}

11 shorter space after the period mark (not end of the sentence but for abbreviations, etc)

\@ eg. Ph.D.\@Shim

12 change font size temporarily

in the followings, we can replace small with the one among tiny, scriptsize, footnotesize, small, normalsize, large, Large, LARGE, huge, Huge

12.1 of an area \begin{small} \end{small}

12.2 of a word {\small WORD}

12.3 as a switcher \small

13 putting a formula inside of a table cell

\parbox{.5em}{\begin{equation*}\end{equation*}} (.5em indicates the size of the padding around the equation)

14 variable

  • add the following to preamble:

    \newcommand{\newCommandName}{text to insert}
    

    Then use \newCommandName{} in the text

15 setcounter enumi

\begin{enumerate}
  \setcounter{enumi}{4}
  \item fifth element
\end{enumerate}

16 newcommand / renewcommand

From 9 :

In LaTeX2ε, users can define commands and environments with up to nine arguments including up to one optional argument.

  • \newcommand {<cmd>} [<num>] [<default>] {<definition>}

  • \newcommand* {<cmd>} [<num>] [<default>] {<definition>}

  • \renewcommand {<cmd>} [<num>] [<default>] {<definition>}

  • \renewcommand* {<cmd>} [<num>] [<default>] {<definition>}

<cmd> is the name of the newly defined command

<num> is the number of arguments that will be referred as #1, #2, #3, etc in order without any enclosing delimiters.

  • Omission: [<num>] part can be omitted when no optional or mandatory argument is required at all. But it should be set to 1 even if an optional argument is needed.

  • optional vs mandatory: the first argument, to be referred later by #1, will automatically be optional if <default> is provided. Others, starting from #2, then become mandatory.

<default> provides the default value for the first argument that becomes optional.

  • If [<default>] is omitted, all the arguments will be regarded as mandatory.

  • Thus, if we want to make an argument optional with empty value, we still need to specify [].

<definition> literally defines a <cmd>.

We use thus defined <cmd> in the document as the following:

\cmd{#1}{#2}{#3}...

and when there is an optional argument,

\cmd[#1]{#2}{#3}...

17 temp

17.1 TDS

A standard TEX Directory Structure (TDS) is a name for a directory hierarchy for macros, fonts, and the other implementation-independent TeX system files.

17.2 texmf

We shall designate the root TDS directory by texmf (that stands for “TEX and MetaFont”).

17.3 magnification

\magnification=<NUMBER>

at the beginning of your manuscript will magnify a document by the factor NUMBER/1000. For example, 1200 will make the document scaled up by the factor 1.2 and 500 will make it smaller by half. This instruction must be given before the first page of output has been completed. You cannot apply two different magnifications to the same document. 1

17.4 hsize

\hsize=<dimen>

17.5 tabbing

From §3.6.1(p.60-61) 10 :

\begin{tabbing}
If \= it's raining          \\     % If it's raining
   \> then \= put on boots, \\     %    then put on boots,
   \>      \> take hat;     \\     %         take hat;
   \> else \> smile.        \\     %    else smile.
Leave house.                       % Leave house.
\end{tabbing}

17.6 multicolumn

We can use the following in the environments tabular and longtable. See §3.6.2(p.62) 10 .

\multicolumn{N}{POS}{ITEM}
  • N is the number of columns to be spanned.

  • HPOS specifies the positionalspecifiers of the item. See “§ Tabular/array horizontal column formatting” and “§ Tabular/array vertical column formatting”.

  • ITEM is the item’s text (content).

17.7 mbox

\mbox command causes TeX to process its argument in LR mode. See “§ Text modes”.

17.8 extracolsep

See “§ Tabular/array horizontal column formatting”.

18 Text modes

From Chap 3 (p.36) 11 :

As LaTeX processes the input text, it is always in one of the following three modes. Different modes can be nested within one another.

18.1 paragraph mode

Paragraph mode is LaTeX’s normal mod~the one it’s in when processing ordinary text. In paragraph mode, TeX regards your input as a sequence of words and sentences to be broken into lines, paragraphs, and pages.

18.2 math mode

TeX is in math mode when it’s generating a new line mathematical formula.

18.3 left-to-right mode (LR mode)

In LR mode, as in paragraph mode, TeX considers your input to be a string of words with spaces between them. However, unlike paragraph mode, TeX produces output that keeps going from left to right; it never starts a new line in LR mode. The \mbox command causes TeX to process its argument in LR mode, which is what prevents the argument from being broken across lines.

19 LR mode

LR mode is a text mode in which TeX does not insert a new line for the lin e breaking. See “§ Text modes”.

20 Tabular/array vertical column formatting

From §C.10.2(p.204) 10 :

The environments array, tabular, tabular*, longtable optionally take the horizontal formatting argument (with [...] instead of {...}).

  • t align to the top

  • b align to the bottom

  • m align to the middle (CHECK THIS!)

21 Tabular/array horizontal column formatting

From §C.10.1(p.205) 10 :

The environments array, tabular, tabular*, longtable mandate the horizontal formatting argument. This consists of a sequence of the following specifiers, corresponding to the sequence of columns and inter-column material.

  • l a left-aligned column

  • r a right-aligned column

  • c a column with centered text

  • | a vertical line the full height and depth of the environment

  • @{TEXT} so called an @-expression that inserts TEXT in every row and suppresses the space LaTeX normally inserts between columns. MyNote: the column delimiter | is the same as @{<DEFAULT_DIST> | <DEFAULT_DIST>}.

    • TEXT is processed in math mode in the array environment

    • TEXT is processed in LR mode in the tabular and tabular* environments.

    • TEXT is considered a moving argument.

    • Any desired space between the inserted text and the adjacent items must be included in TEXT.

      • To change the space between two columns from the default to WD, put an @{\hspace{WD}} command between the corresponding column specifiers.

      • An \extracolsep{WD} command in an @-expression causes an extra space of width WD to appear to the left of all subsequent columns, until countermanded by another \extracolsep command. (However, it will not put space to the left of the first column.) An \extracolsep command can be used only in an @-expression.

      • It is most commonly used to insert a \fill space in a tabular* environment.

  • p{WD} Produces a column with each item typeset in a parbox of width WD, as if it were the argument of a \parbox[t]{WD} command. However, a \\ may not appear in the item, except in the following situations:

    • inside an environment like minipage, array, or tabular

    • inside an explicit \parbox, or

    • in the scope of a \centering, \raggedright, or \raggedleft declaration. The latter declarations must appear inside braces or an environment when used in a p-column element.

  • \*{NUM}{COLS} Equivalent to NUM copies of COLS, where NUM is any positive integer and COLS is any list of column-specifiers, which may contain another *-expression.

22 @-expression

See “§ Tabular/array horizontal column formatting”.

23 Internal registers and parameters

A <DIMEN> can refer to some multiples of TeX’s internal registers or parameters. For example, where \hsize stands for the current horizontal line size, .5\hsize is half of that amount, 2\hsize double, -\hsize the negative. 11

In LaTeX, \parindent is a length command whose value specifies the width of the indentation at the beginning of a normal paragraph. We can type 2.5\parindent for a length that is 2.5 times large, or -2.5\parindent for the negative 2.5 times large.

24 LaTeX dimension parameters

See §6.4(p.101) 10

  • \parindent

  • \textwidth

  • \textheight

  • \parskip

  • \baselineskip

25 LaTeX dimension declarations

See §6.4(p.101) 10

  • \newlength

  • \setlength

  • \addtolength

  • \settowidth

  • \settoheight

  • \settoheight

26 Fragile commands

From §2.2.3(p22) 10 :

Commands that are not fragile will be called robust. An argument in which fragile commands need protect will be called a moving argument, eg. the argument for \section.

  • \( ... \) is fragile while $ ... $ is not.

  • \begin ... \end is fragile

  • \footnote is fragile

On the rare occasions when you have to put a fragile command in a section title, you simply protect it with a \protect command. The \protect command goes right before every fragile command’s name, eg:

\subsection {Is \protect\( x+y \protect\) Prime?}

The \protect command can’t hurt, so it is almost always safe to use one when you’re not sure if the command is fragile or robust.

27 Robust commands

Commands that are not fragile will be called robust. See “§ Fragile commands”.

28 Moving argument

An argument in which fragile commands need protect will be called a moving argument, eg. the argument for \section. See “§ Fragile commands”.

29 Misc / Maintenance journal

  • [2020-11-16 Mon 18:11] found out spectralsequences package does not work with pgf/tikz from TeXLive 2020. It works good not after making pgf points to the 2019 version:

    • renamed texlive/2020/texmf-dist/tex/generic/pgf into texlive/2020/texmf-dist/tex/generic/pgf.2020 and

    • made a sym-link texlive/2020/texmf-dist/tex/generic/pgf.2020/pgf pointing to the old texlive/2019/texmf-dist/tex/generic/pgf.

30 define macros with *

The following example defines a macro \includesnippet that can be used as either \includesnippet{AAA} or \includesnippet*{AAA}:

\makeatletter
\def\includesnippet{\@ifstar\@includesnippet\@@includesnippet}
\def\@includesnippet#1{{\renewcommand{\label}{\mytag}\subfile{./snippets/#1.tex}}}
\def\@@includesnippet#1{\subfile{./snippets/#1.tex}}
\makeatother
  • \def\@includesnippet defines \includesnippet*

  • \def\@@includesnippet defines \includesnippet

1(1,2,3)

https://en.wikipedia.org/wiki/Device_independent_file_format

2

https://en.wikipedia.org/wiki/PostScript

3(1,2)

https://en.wikipedia.org/wiki/Metafont

4

https://en.wikipedia.org/wiki/Encapsulated_PostScript

5

https://en.wikipedia.org/wiki/Computer_font

6

https://en.wikipedia.org/wiki/Ghostscript

7

https://www.aivosto.com/articles/imageformats.html

8

https://www.sitepoint.com/gif-png-jpg-which-one-to-use/

9

LaTeX3 Project Team, LaTeX2ε for authors, 25 May 2020

10(1,2,3,4,5,6,7)

Leslie Lamport, Latex: A Document Preparation System, 1989

11(1,2)

Donald E. Knuth, The TeXbook, 1986