X-Git-Url: https://git.distorted.org.uk/~mdw/mdwtools/blobdiff_plain/c55b9cc88871282bb3ecc28eb12f63382d8b4d2b..6a1388ae98e3c04d9d0bf4d99249b228a7934bd9:/mdwtools.tex diff --git a/mdwtools.tex b/mdwtools.tex index 1a0d37e..c8e8932 100644 --- a/mdwtools.tex +++ b/mdwtools.tex @@ -36,7 +36,7 @@ % % \end{meta-comment} % -% \CheckSum{709} +% \CheckSum{804} %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z @@ -225,13 +225,26 @@ % loaded is by seeing if the |\documentclass| command has been redefined % to raise an error. This isn't too hard, really. % +% If my \package{strayman} document class is available, then I'd prefer to +% use that. +% % \begin{macrocode} \ifx\documentclass\@twoclasseserror\else - \documentclass[a4paper]{ltxdoc} + \IfFileExists{strayman.cls} + {\documentclass[a4paper]{strayman}} + {\documentclass[a4paper]{ltxdoc}} \ifx\doneclasses\mdw@undefined\else\doneclasses\fi \fi % \end{macrocode} % +% If I can use better fonts, then that would be nice. +% +% \begin{macrocode} +\usepackage[T1]{fontenc} +\IfFileExists{mdwfonts.sty} + {\usepackage[palatino, helvetica, courier, maths=cmr]{mdwfonts}}{} +% \end{macrocode} +% % As part of my standard environment, I'll load some of my more useful % packages. If they're already loaded (possibly with different options), % I'll not try to load them again. @@ -242,7 +255,32 @@ \@ifpackageloaded{sverb}{}{\usepackage{sverb}} % \end{macrocode} % +% If I'm not using the \package{ltxdoc} document class then I'll need some of +% its definitions. I've no idea why these aren't part of \package{doc}\ldots +% +% \begin{macro}{\cmd} +% \begin{macro}{\cs} +% \begin{macrocode} +\def\cmd#1{\expandafter\cmd@i\string#1\x} +\def\cmd@i#1#2\x{\cs{#2}} +\DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}} +% \end{macrocode} +% \end{macro} +% \end{macro} % +% \begin{macro}{\marg} +% \begin{macro}{\oarg} +% \begin{macro}{\parg} +% \begin{macrocode} +\def\@arg#1#2#3{\texttt{#1}\meta{#2}\texttt{#3}} +\def\marg#1{\@arg{\char`\{}{#1}{\char`\}}} +\def\oarg#1{\@arg{[}{#1}{]}} +\def\parg#1{\@arg{(}{#1}{)}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} + % \subsection{Some macros for interaction} % % I like the \LaTeX\ star-boxes, although it's a pain having to cope with @@ -440,6 +478,33 @@ % \end{macrocode} % % +% \subsection{Custom description lists} +% +% For some bizarre reason, the \LaTeX\ \env{description} environment sets +% |\itemindent| so that the label starts |\labelsep| into the left margin, +% and the default |\makelabel| must therefore contain a hack to compensate. +% This is fixed in the \package{strayman} document class, and by the +% \package{mdwlist} package in this collection. But this introduces a +% problem: if I want to set a \env{description} list with custom labels, how +% can I do this without messing up the spacing? +% +% Detection of the relevant packages is done in an awfully hacky way, because +% \LaTeXe\ seems to go out of its way to forget which packages have been +% loaded at |\begin{document}| time. +% +% \begin{macrocode} +\def\setdescriptionlabel#1{% + \if1\ifx\sectindent\xxundefined% strayman? + \ifx\defaultdesc\xxundefined% mdwlist? + 1\else0\fi\else0\fi% + \def\makelabel##1{\hskip\labelsep\relax#1}% + \else% + \def\makelabel##1{#1}% + \fi% +} +% \end{macrocode} +% +% % \subsection{A table environment} % % \begin{environment}{tab} @@ -972,7 +1037,8 @@ % The first job is to add the previous item to the title string. If this % is the first item, though, I'll just add the appropriate \lit{The } or % \lit{ and the } string to the title (this is stored in the |\@prefix| -% macro). +% macro). Also maintain a parallel version which doesn't have the footnotes +% in: this will be suitable for a running header. % % \begin{macrocode} \edef\mdw@title{% @@ -982,6 +1048,13 @@ \else,\@prevnote\ \@nextitem% \fi% }% + \edef\mdw@runningtitle{% + \mdw@runningtitle% + \ifcase\count@\@prefix% + \or\@nextitem% + \else, \@nextitem% + \fi% + }% % \end{macrocode} % % That was rather easy. Now I'll set up the |\@previtem| and |\@nextitem| @@ -1023,6 +1096,14 @@ \else,\@prevnote\ and \@nextitem\@nextnote\space#4% \fi% }% + \edef\mdw@runningtitle{% + \mdw@runningtitle% + \ifcase\count@% + \or\@nextitem\space#3% + \or\ and \@nextitem\space#4% + \else,\ and \@nextitem\space#4% + \fi% + }% % \end{macrocode} % % Finally, if $|\count@| \ne 0$, I must set |\@prefix| to \lit{ and the }. @@ -1064,6 +1145,7 @@ % % \begin{macrocode} \def\mdw@title{}% + \def\mdw@runningtitle{}% \def\@prefix{The }% % \end{macrocode} % @@ -1079,7 +1161,11 @@ % following hacking will do this. % % \begin{macrocode} - \edef\next{\endgroup\noexpand\title{\noexpand\mdw@titlehack\mdw@title}}% + \edef\next{% + \endgroup% + \noexpand\title{\noexpand\mdw@titlehack\mdw@title}% + \def\noexpand\@headertitle{\mdw@runningtitle}% + }% \next% } % \end{macrocode} @@ -1157,11 +1243,11 @@ % % \begin{macrocode} \def\do##1##2{% - ##2% \ifhave@multicol\addtocontents{##1}{% \protect\begin{multicols}{2}% \hbadness\@M% }\fi% + ##2% }% \docontents% % \end{macrocode}