From 3ee5a99a4a80a83f9199e1dfe1c1ef4c9d971d67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Novotn=C3=BD?= Date: Thu, 26 Aug 2021 21:18:58 +0200 Subject: [PATCH] Add index to the documentation --- latexmkrc | 1 + markdown.dtx | 46 ++++++++++++++++++++++++++++++++++------------ markdown.ist | 3 +++ 3 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 markdown.ist diff --git a/latexmkrc b/latexmkrc index 34d796211..a9b6a23ef 100644 --- a/latexmkrc +++ b/latexmkrc @@ -1,4 +1,5 @@ $pdflatex = 'lualatex --shell-escape %O %S'; +$makeindex = 'makeindex -s %R.ist %O -o %D %S'; $pdf_mode = 1; $postscript_mode = 0; $dvi_mode = 0; diff --git a/markdown.dtx b/markdown.dtx index 7a5472d2a..52d39d5a3 100644 --- a/markdown.dtx +++ b/markdown.dtx @@ -30,29 +30,50 @@ % Define some markup. \let\pkg\relax % A package name +\def\inline#1{% Inline code + \textcolor{spot}{\text{\texttt{#1}}}} +\newcommand\acro[1]{% An acronym + \textsc{\MakeLowercase{#1}}} + +% Set up index. +\DisableCrossrefs +\IndexPrologue{% + \section*{\indexname}% + \addcontentsline{toc}{section}{\indexname}} +\makeatletter\c@IndexColumns=2\makeatother +\usepackage{makeidx} +\makeindex + \newcommand\mdef[1]{% A TeX macro definition + \index{#1@\cs{#1}|textit}% \phantomsection\label{macro:#1}\textcolor{spot}{\cs{#1}}} \newcommand\m[1]{% A TeX macro reference + \index{#1@\cs{#1}}% \hyperref[macro:#1]{\textcolor{spot}{\cs{#1}}}} -\newcommand\envmdef[1]{% A TeX macro definition - \phantomsection\label{environment:#1}\t`#1`} + +\newcommand\envmdef[1]{% A LaTeX environment definition + \index{#1@\texttt{#1}|textit}% + \phantomsection\label{environment:#1}\inline{#1}} \newcommand\envm[1]{% A LaTeX environment reference - \hyperref[environment:#1]{\t`#1`}} + \index{#1@\texttt{#1}}% + \hyperref[environment:#1]{\inline{#1}}} + \newcommand\luamdef[1]{% A Lua object / method definition - \phantomsection\label{lua:#1}\t`#1`} + \index{#1@\texttt{#1}|textit}% + \phantomsection\label{lua:#1}\inline{#1}} \newcommand\luam[1]{% A Lua object / method reference - \hyperref[lua:#1]{\t`#1`}} -\def\inline#1{% Inline code - \textcolor{spot}{\text{\texttt{#1}}}} -\def\t`#1`{\inline{#1}} + \index{#1@\texttt{#1}}% + \hyperref[lua:#1]{\inline{#1}}} + \newcommand\Optitem[2][]{\penalty -1000\relax % An option item definition + \index{#2@\texttt{#2}|textit}% \phantomsection\label{opt:#2}\optitem[#1]{#2}} \newcommand\Valitem[2][]{\penalty -1000\relax % A value item definition + \index{#2@\texttt{#2}}% \phantomsection\label{opt:#2}\valitem[#1]{#2}} \newcommand\Opt[1]{% An option / value item reference - \hyperref[opt:#1]{\t`#1`}} -\newcommand\acro[1]{% An acronym - \textsc{\MakeLowercase{#1}}} + \index{#1@\texttt{#1}}% + \hyperref[opt:#1]{\inline{#1}}} % Set up markdown. \usepackage[ @@ -366,7 +387,8 @@ \printtitlepage \tableofcontents \DocInput{markdown.dtx} -\printbibliography +\printbibliography[heading=bibintoc] +\printindex \end{document} % %<*manual-css> diff --git a/markdown.ist b/markdown.ist new file mode 100644 index 000000000..7e01ae03e --- /dev/null +++ b/markdown.ist @@ -0,0 +1,3 @@ +delim_0 "\\hfill" +delim_1 "\\hfill" +delim_2 "\\hfill"