Created
August 15, 2012 09:57
-
-
Save zr-tex8r/3358339 to your computer and use it in GitHub Desktop.
An example of \ifnum`{=0\fi trick
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% defqverb.sty | |
%%<*> \begin{defqverb}\CS<content>\end{defqverb} | |
% Makes \CS a macro that expands to the token list that is obtaned | |
% by full-expanding <content> in verbatim except \, {, and }. | |
% Here a newline character is converted to \par. | |
\def\defqverb#1{% | |
\xx@obeylines | |
\let\do\@makeother \xx@specials | |
\gdef\xx@finale{\let#1\xx@g@tempa}% | |
\xdef\xx@g@tempa{\ifnum`}=\z@\fi | |
} | |
\def\enddefqverb{% | |
\ifnum`{=\z@\fi}% | |
\aftergroup\xx@finale | |
} | |
\def\xx@specials{\do\ \do\$\do\&\do\#\do\^\do\_\do\%\do\~} | |
\begingroup\endlinechar\m@ne | |
\catcode13=\active | |
\gdef\xx@obeylines{\catcode13=\active \def^^M{\noexpand\par}}% | |
\endgroup | |
%% EOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% test-defqverb.tex | |
\documentclass{article} | |
\usepackage{defqverb} | |
\newcommand\Test[1]{TEST[#1]} | |
\begin{defqverb}\Sample | |
\Test{#%$%#} | |
OK! | |
\end{defqverb} | |
\begin{document} | |
\show\Sample % show the meaning of \Sample | |
\Sample | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment