\input opmac \def\toasciidata{}\def\r{} \typosize[11/13] %\def\thefnote{$^{\locfnum}$} \addto\footstrut{\hang} \catcode`<=13 \def<#1>{\hbox{$\langle$\it#1\/$\rangle$}} \activettchar" \hyperlinks{\Blue}{\Green} \insertoutline{CONTENTS} \outlines{0} \tit OPmac -- macros for plain\TeX\fnotemark1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \centerline{\it Petr Ol\v s\'ak, 2012, 2013, 2014} \bigskip \centerline{\url{http://petr.olsak.net/opmac-e.html}} \fnotetext {This text is second revised version. The first version was published in TUGboat 34:1, 2013, pp.~88--96} \notoc\nonum \sec Contents \maketoc \nonum \sec Introduction %%%%%%%%%%%% The OPmac package is a set of simple additional macros to plain\TeX{}. It enables users to take advantage of basic \LaTeX{} functionality: font size selection, the automatic creation of a table of contents and an index, working with bibliography databases, tables, references with optional hyperlinks, margin settings, etc. I had been using these macros personally for a long time, but now, after cleaning up the code a bit and providing both user and technical documentation, I'm releasing them to the general public along with the new version of \csplain{}. My main motivation in publishing OPmac is to provide a set of macros with solutions to common tasks for plain\TeX{} users. Additionally, I wanted to demonstrate that it is possible to write \TeX{} code in a simple and effective style, something that most \LaTeX{} macro packages lack. All of OPmac's macros are contained within the single file "opmac.tex" in only 1,700 lines. By comparison, the \LaTeX{} code which solves comparable tasks is placed inside its ``kernel'' along with many \LaTeX{} packages all of which contain tens of thousands of lines. The main principles which I followed when creating this macro package, are: \begitems * Simplicity is power. * Macros are not universal, but are readable and understandable. * User can easily redefine these macros as he/she wishes. \enditems Each part of the macro code is written in order to maximize readability for human who will want to read it, understand it and change it. OPmac package offers a markup language for authors of texts (like \LaTeX), i.e. the fixed set of tags to define the structure of the document. This markup is different from the \LaTeX{} markup. It may offer to write the source text of the document somewhat clearer and more attractive. The OPmac package, however, does not care for the typography of the document. The simple sober document is created if no additional macros are used. We assume that the author of additional macros is able to create a look of the document to suit specific requirement. OPmac has a small number of additional packages: "pdfuni", "opmac-xetex" and "opmac-bib" (see the end of \url{http://petr.olsak.net/opmac-e.html} page). Moreover, there exist many tens of little OPmac tricks comparable with \LaTeX{} packages mentioned on \url{http://petr.olsak.net/opmac-tricks-e.html} page. \secnum=-1 \sec Using OPmac %%%%%%%%%%%%%%%% OPmac is not compiled as a format. For using it in plain\TeX{}, you can simply "\input opmac" at the beginning of your document. The example of the simple document follows: \begtt \input opmac \typosize[11/13] % setting the basic font size and the baselineskip \margins/1 a4 (1,1,1,1)in % setting 1in margins for A4 paper Here is a text. \bye \endtt You can use \TeX, pdf\TeX, Xe\TeX{} or lua\TeX{} with plain \TeX{} format (classical "plain.tex", "etex.src" or \csplain{}). The \csplain{} is recommended but it is not explicitly requested if you don't need to use Czech/Slovak specific features\fnote {Warnings: ``falling back to ASCII sorting'' or ``CZ/SK outline-conversion is off'' may occur without \csplain{}.}. \sec Font sizes %%%%%%%%%%%%%%% The commands for font size setting described here have local validity. It means that if you put them into group, the font sizes are selected locally. The command "\typosize[/]" sets the font size of text and math fonts and baselineskip. If one of these two parameters is empty, the corresponding feature stays unchanged. The metric unit is supposed "pt" and this unit isn't written in parameters. You can change the unit by the command "\ptunit=", for instance "\ptunit=1mm". Examples: \begtt \typosize[10/12] % default of plainTeX \typosize[11/12.5] % font 11pt, baseline 12.5pt \typosize[8/] % font 8pt, baseline unchanged \endtt The command "\typoscale[/]" sets the text and math fonts size and baselineskip as a multiple of the current fonts size and baselineskip. The factor is written in "scaled"-like way, it means that 1000 means factor one. The empty parameter is equal to the parameter 1000, i.e. the value stays unchanged. Examples: \begtt \typoscale[800/800] % fonts and baselineskip re-size to 80 % \typoscale[\magstep2/] % fonts bigger 1,44times \endtt The sizes declared by these macros (for example in titles) are relative to the basic size selected for the current font (this may be arbitrary size, not only 10pt). There are times however, when one would like to make a font change relative to the documents ``base'' font size instead of the current font (e.g. when typesetting footnotes). The macro "\typobase" provides an easy way to perform such changes. The ``base'' font size is set with the first use of either "\typosize" or "\typoscale" and this size is restored by "\typobase". Example: \begtt \typosize[12/14] % if first use of \typosize, then this sets the "base" ... {\typoscale[16/18] % bigger size (for example title font) ... \typobase\typoscale[750/750] % reduced to 75% of [12/14] (i.e. [9/10.5]) ... % this is caculated from "base", no from actual title font } \endtt The size of the current font can be changed by the command "\thefontsize[]" or can be rescaled by "\thefontscale[]". These macros don't change math fonts sizes nor baselineskip. The "\resizefont", "\regfont" and "\resizeall" commands (documented in \csplain) can be used even if the used format is not \csplain. The best design size of the font for desired size is selected. For example "\typosize[18/]" selects the font "cmr17 at 18pt". The "\em" macro acts as "\it" if the current font is "\rm", acts as "\rm" if the current font is "\it", acts as "\bi" if the current font is "\bf" and acts as "\bf" if the current font is "\bi". The "\/" spaces are inserted automatically. Example: \begtt This is {\em important} text. % = This is {\it important\/} text. \it This is {\em important} text. % = This is\/ {\rm important} text. \bf This is {\em important} text. % = This is {\bi important\/} text. \bi This is {\em important} text. % = This is\/ {\bf important} text. \endtt \sec Parts of the document %%%%%%%%%%%%%%%%%%%%%%%%%% The document can be divided into chapters, sections and subsections and titled by "\tit" command. The parameters are separed by the end of current line (no braces are used): \begtt \tit Document title \chap Chapter title \sec Section title \secc Subsection title \endtt The chapters are numbered by one number, sections by two numbers (chapter.section) and subsections by three numbers. If there are no chapters then section have only one number and subsection two. The implicit design of the titles of chapter etc.\ are implemented in the macros "\printchap", "\printsec" and "\printsecc". User can simply change these macros if he/she needs another behavior. The first paragraph after the title of chapter, section and subsection is not indented but you can type "\let\firstnoindent=\relax" if you need all paragraphs indented. If a title is so long then it breaks to more lines. It is better to hint the breakpoints because \TeX{} does not interpret the meaning of the title. User can put the "\nl" (it means newline) macro to the breakpoints. The chapter, section or subsection isn't numbered if the "\nonum" precedes. And the chapter, section or subsection isn't delivered to the table of contents if "\notoc" precedes. \sec Another numbered objects %%%%%%%%%%%%%%%%%%%%%%%%%%%%% Apart from chapters, sections and subsections, there are another automatically numbered objects: equations and captions for tables and figures. If user write the "\eqmark" as the last element of the display mode then this equation is numbered. The format is one number in brackets. This number is reset in each section. If the "\eqalignno" is used, then user can put "\eqmark" to the last column before "\cr". For example: \begtt \eqalignno{ a^2+b^2 &= c^2 \cr c &= \sqrt{a^2+b^2} & \eqmark \cr} \endtt The next numbered object is caption which is tagged by "\caption/t" for tables and "\caption/f" for figures. Example: \begtt \hfil\table{rl}{ age & value \crl\noalign{\smallskip} 0--1 & unmeasured \cr 1--6 & observable \cr 6--12 & significant \cr 12--20 & extremal \cr 20--40 & normal \cr 40--60 & various \cr 60--$\infty$ & moderate} \par\nobreak\medskip \caption/t The dependency of the computer-dependency on the age. \endtt This example produces: \bigskip {\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}} \hfil\table{rl}{age & value \crl\noalign{\smallskip} 0--1 & unmeasured \cr 1--6 & observable \cr 6--12 & significant \cr 12--20 & extremal \cr 20--40 & normal \cr 40--60 & various \cr 60--$\infty$ & moderate} \par\nobreak\medskip { \leftskip=\parindent plus1fil \rightskip=\parindent plus-1fil \parfillskip=0pt plus2fil \noindent {\bf Table 2.3} The dependency of the com\-puter-dependency on the age.\par} } \bigskip The word ``Table'' followed by a number is added by the macro "\caption/t". The macro "\caption/f" creates the word figure. The caption text is centered. If it occupies more lines then the last line is centered. The added word (table, figure) depends on the actual number of the "\language" register. OPmac implements the mapping from "\language" numbers to the languages and the mapping from languages to the generated words. If you wish to make the table or figure as floating object, you need to use plain\TeX{} macros "\midinsert", "\topinsert" and "\endinsert". Each automatically numbered object can be referenced, if the "\label[