% \begin{meta-comment} % % $Id: mdwref.dtx,v 1.3 2003/11/10 14:43:48 mdw Exp $ % % Slightly fancy cross-referencing stuff % % (c) 2007 Mark Wooding % % \end{meta-comment} % % \begin{meta-comment} %% %% mdwref package -- slightly fancy cross-referencing stuff %% Copyright (c) 2007 Mark Wooding %% %% This program is free software; you can redistribute it and/or modify %% it under the terms of the GNU General Public License as published by %% the Free Software Foundation; either version 2 of the License, or %% (at your option) any later version. %% %% This program is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied warranty of %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %% GNU General Public License for more details. %% %% You should have received a copy of the GNU General Public License %% along with this program; if not, write to the Free Software %% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %% % \end{meta-comment} % % \begin{meta-comment} %<+package>\NeedsTeXFormat{LaTeX2e} %<+package>\ProvidesPackage{mdwref} %<+package> [2007/04/09 1.01 Cross-referencing] % \end{meta-comment} % % ^^A\CheckSum{96} %% \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 %% Digits \0\1\2\3\4\5\6\7\8\9 %% Exclamation \! Double quote \" Hash (number) \# %% Dollar \$ Percent \% Ampersand \& %% Acute accent \' Left paren \( Right paren \) %% Asterisk \* Plus \+ Comma \, %% Minus \- Point \. Solidus \/ %% Colon \: Semicolon \; Less than \< %% Equals \= Greater than \> Question mark \? %% Commercial at \@ Left bracket \[ Backslash \\ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} %% % % \begin{meta-comment} % %<*driver> \input{mdwtools} \describespackage{mdwref} \usepackage{mdwtab} \mdwdoc % % % \end{meta-comment} % %^^A------------------------------------------------------------------------- % % \section{User guide} % % I always name my cross-reference labels with a prefix telling me what kind % of thing they are. A figure might be |fig:foo| or a table |tab:bar|. When % I refer to the thing, then, I basically have to repeat myself: % `|see table~\ref{tab:bar}|'. Kinda silly. % % \DescribeMacro\xref % The |\xref| command understands my prefixing system. I can say % `|\xref{tab:bar}|' and it inserts a reference to `table~4', for example. % This is, of course, useless if you want to put the reference at the % beginning of a sentence: `Table~4 shows\dots'. % \DescribeMacro\Xref % The |\Xref| command (note the initial capital) handles this properly, so % you just type `|\Xref{tab:bar} shows|\dots'. % % The full syntax of the |\xref| command is like this. % \begin{grammar} % ::= \[[ % "\\xref" % \[ "[" "]" \] % "{" "}" % \]] % \end{grammar} % The optional \ argument is a command to be applied to the generated % text: it \emph{must} be a single token. Rather than printing `table', or % whatever, it prints \syntax{"{table}"}. % The most obvious application of this is the |\Xref| command, which uses a % helper |\toupper|. % \DescribeMacro\toupper % The call \syntax{"\\toupper{""}"} typesets \ with the first % character in uppercase. So |\Xref| is defined simply as\footnote{Modulo % the fact that the author is a dreadful \TeX\ hacker.} % \begin{listing} %\newcommand{\Xref}[1]{\xref[\toupper]{#1}} % \end{listing} % % \DescribeMacro\formatxref % The reference itself is typeset by calling % \syntax{"\\formatxref{""}{""}{" % \end{macrocode} % \nopagebreak % % \hfill Mark Wooding, \today % % \Finale % \endinput