stx2any — definitions for LaTeX

This file is copyright © 2004,2005,2006 by Panu Kalliokoski and released under the license in ../LICENSE

Note that the definitions won't look right in the target output format, because they contain target markup.

Definitions for LaTeX.

LaTeX provides its own hack diversion, preamble. There is also some neatism to its own name.

w_define_div(preamble)
define(`LaTeX', ``\LaTeX{}'')
define(`@w_documentclass', `article')
define(`w_documentclass', `w_set_or_get(`@w_documentclass', `$1')')

Some macros (URLs and inline graphics) need package declarations. We use this to only include them once.

define(`w_ensure_pkg',
`ifdef(`@w_has_pkg_$1',,
  `define(`@w_has_pkg_$1',t)w_begdiv(preamble)\usepackage{$1}
w_enddiv(preamble)')')

Paragraphs and headings.

We leave paragraphs to LaTeX itself. It has similar paragraph rules to ours.

define(`w_paragraph',)
define(`w_headl',
`w_newindent(0)'dnl
`\w_pickn($1, section, subsection, subsubsection, paragraph)`''dnl
`ifelse(w_do_numbering,true,,*)'dnl
`{ifelse(w_do_link_abbr,true,`w_autolabel(`$2')',`$2')}')

Block system environments.

Finding definitions in lists is left to LaTeX. It has similar rules to ours.

w_define_env(-, `\begin{itemize}w_nl`'', `\end{itemize}w_nl`'')
w_define_env(#, `\begin{enumerate}w_nl`'', `\end{enumerate}w_nl`'')
w_define_env(:, `\begin{description}w_nl`'', `\end{description}w_nl`'')
w_define_env(q, `\begin{quotation}w_nl`'', `\end{quotation}w_nl`'')
w_define_env(t,,)
define(`w_listitem', `\item ')
define(`w_defnterm', `\item[{$1}] ')

Other environments.

w_define_env(`footnote', `\footnote{', `}')
w_define_env(`litblock', `w_ensure_pkg(alltt)\begin{alltt}', `\end{alltt}')
w_define_env(`center', `\begin{center}', `\end{center}')
w_define_env(`abstract',
`w_begdiv(ingr)\begin{abstract}`'w_nl',
`\end{abstract}w_enddiv(ingr)`'w_nl')
w_define_env(`comment',
`pushdef(`w_softbr', `% ')pushdef(`w_softpara', `% ')% ',
`w_nl`'popdef(`w_softbr')popdef(`w_softpara'){}')
w_define_env(`w_float_n',
`\begin{figure}[htb]', `\caption{$1}w_nl\end{figure}')
w_define_env(`w_float_f',
`\begin{figure}[tbp]', `\caption{$1}w_nl\end{figure}')
w_define_env(`w_float_m', `\marginpar{', `\\ $1 }')

Emphasis.

define(`w_literal', `\litfmt{$1}')
define(`w_emph', `\emph{$1}')
define(`w_strong', `\strongemph{$1}')

Other inlines.

define(`w_linebr', `\\')
define(`w_sectbreak',
`w_nl\begin{center}\rule{0.5\textwidth}{0.0$1em}\end{center}w_nl')
define(`w_link', `w_ensure_pkg(url)`'$2`'w_footnote(`\url{$1}')')
define(`w_img',
`w_ensure_pkg(graphicx)\includegraphics{w_file(`$1.'w_picture_suffix)}')
define(`w_label', `\label{$1}$2')
define(`w_refer', `$2 (\pageref{$1})')
define(`w_url', `w_ensure_pkg(url)\url{$1}')

Slides.

w_define_env(`slide', `w_ensure_slides\begin{slide}', `\end{slide}')

define(`w_ensure_slides', `w_documentclass(seminar)'dnl
`ifdef(`@w_slidestyle_done',,
`define(`@w_slidestyle_done',t)undefine(`w_make_title')'dnl
`define(`@w_doctype_parms',
w_gather(patsubst(defn(`@w_doctype_parms'), a4paper, a4)))'dnl
`ifelse(w_slideheader`'w_slidefooter,,,`w_slidestyle_setup')')')

define(`w_slidestyle_setup',
`w_begdiv(preamble)\newpagestyle{slidepage}
{\hfill{}w_slideheader\hfill{}}{\hfill{}w_slidefooter\hfill{}}
w_enddiv(preamble)w_begdiv(frontmatter)\slidepagestyle{slidepage}
w_enddiv(frontmatter)')

Tables.

define(`w_make_tablespec',
`ifelse(`$*',,,
  `ifelse(`$1',p,`p{0.3\textwidth}',`$1')`'w_make_tablespec(shift($@))')')
w_define_env(`w_table',
`pushdef(`w_caption', `\caption{$1}')'dnl
`\begin{tabular}{w_make_tablespec($@)}w_nl',
`popdef(`w_caption')\end{tabular}w_nl')
w_define_env(`w_row',,`undefine(`@w_in_row_flag')\\')
w_define_env(`w_cell',
`ifdef(`@w_in_row_flag',`&')define(`@w_in_row_flag',t)',)
define(`w_table_rule', `\hline')

Special and quoted characters.

define(`w_lt', `\ensuremath{<}')
define(`w_gt', `\ensuremath{>}')
define(`w_bs', `\ensuremath{\backslash}')
define(`w_obr', `\{')
define(`w_bar', `\ensuremath{|}')
define(`w_cbr', `\}')
define(`w_amp', `\&')
define(`w_us', `\_')
define(`w_ct', `\^{}')
define(`w_td', `\~{}')
define(`w_dol', `\$')
define(`w_hs', `\#')
define(`w_pct', `\%')
define(`w_emdash', `---')
define(`w_endash', `--')
define(`w_ellipsis', `\ldots{}')
define(`w_copyrightsign', `\copyright{}')
define(`w_trademarksign', `\texttrademark{}')
define(`w_larrow', `\ensuremath{\leftarrow{}}')
define(`w_rarrow', `\ensuremath{\rightarrow{}}')