%\iffalse -*- doctex -*- \fi % %% \RCS$Id: pmn-code.sty,v 1.1 2004/03/26 23:23:28 turtle Exp $ %% \RCS$Revision: 1.1 $ %% \RCS$Date: 2004/03/26 23:23:28 $ % %\iffalse metacomment % -*- swiftex-dtx -*- %% $Id: pmn-code.sty,v 1.1 2004/03/26 23:23:28 turtle Exp $ %% (C) 2003 Peter Møller Neergaard %% %% This program may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.2 %% of this license or (at your option) any later version. %% The latest version of this license is in %% http://www.latex-project.org/lppl.txt %% and version 1.2 or later is part of all distributions of LaTeX %% version 1999/12/01 or later. % % This program consists of the file pmn-code.sty. % % To print the documentation (which for the moment is uninteresting) % remove you will have to uncomment all the lines starting with %D%. % %\fi % % \CheckSum{10} % \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 \~} % % \MakeShortVerb{\"} % % \title{The \package{pmn-code} package\thanks % {This file has CVS revision \RCSRevision, dated \RCSDate.}} % \author{Peter Møller Neergaard} % \maketitle % % \begin{abstract} % Provides a command \cmd{\code} to typeset code. % \end{abstract} % % % First we announce ourselves to the world. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{pmn-code}[2004/03/26 v0.1 pmn-code] % \end{macrocode} % The package provides a \cs{code} command to typeset code. It uses a % typewriter font and does not permit line break at spaces. % % We need to manipulate the character code of space so we open a group % \begin{macrocode} {\makeatletter \catcode`\ =\active % \end{macrocode} % \begin{macro}{\code} % \begin{macro}{\code@i} % \mcmd{\code}\marg{code snippet} typesets \meta{code snippet} in % type writer font. We change the space to provide an unbreakable % space using \cmd{\onespace}. % \begin{macrocode} \gdef\code{% \bgroup% \catcode`\ =\active%  \let \onespace% \code@i}% \gdef\code@i#1{% \textnormal{\texttt{#1}}% \egroup}% % \end{macrocode} % \end{macro}^^A \code@i % \end{macro}^^A \code % % \begin{macro}{\onespace} % \begin{macro}{\@gobblespaces} % \begin{macro}{\@gobblespaces@i} % \begin{macro}{\@gobblespaces@ii} % \mcmd{\onespace} parses consecutive occurrences of a space in the % input and turns them into one single unbreakable space. This is % the usual \LaTeX\ convention except that the space is unbreakable. % \begin{macrocode} \gdef\onespace{\ifmmode\else\unskip\expandafter\@gobblespaces\fi} \gdef\@gobblespaces{\futurelet\@let@token\@gobblespaces@i} \gdef\@gobblespaces@i{% \ifx\@let@token % \expandafter\@gobblespaces@ii% \else% \expandafter\nobreakspace% \fi} \gdef\@gobblespaces@ii#1{\@gobblespaces} % \end{macrocode} % In math mode we do nothing since space is automatically ignored. % Otherwise, the next character is continuously eaten as long as it % is a space token. After the last token has been eaten, an % unbreakable space is inserted. % \end{macro}^^A \@gobblespaces@ii % \end{macro}^^A \@gobblespaces@i % \end{macro}^^A \@gobblespaces % \end{macro}^^A \onespace % % \begin{macrocode} \let \space} % \end{macrocode} % If we encounter a space (e.g., in a macro expansion); just let it % have its usual meaning. % \StopEventually % % % And then commands to typeset the documentation. All enclosed in % "<*documentation>"$\ldots$"" so we exclude it if we % ever make a \package{docstrip} file. For now, we simply stop input % with \cmd{\endinput} so the file can be used directly as a package % file. % \begin{macrocode} %<*documentation> \endinput \documentclass{pmn-ldoc} \newcommand{\docdate}{2004/03/26} \usepackage[latin1]{inputenc} % \OnlyDescription % \DisableCrossrefs \begin{document} \DocInput{pmn-code.sty} \end{document} % % \end{macrocode} % \Finale \sloppy \PrintChanges