Latex \newcommand for \end{verbatim} et.al not working -


i'm trying make latex usable, introducing timesavers, i'm having trouble defining new commands terminate environments, @ random.

this works:
\newcommand{\bcv}{\ensuremath{\begin{smallmatrix}}} \newcommand{\ecv}{\ensuremath{\end{smallmatrix}}} \newcommand{\be}{\begin{enumerate}}
\newcommand{\ee}{\end{enumerate}}

this not work:
\newcommand{\bal}{\begin{align*}}
\newcommand{\eal}{\end{align*}}

\newcommand{\verbass}[1]{\begin{verbatim} #1 \end {verbatim}}

specifically, think \end value ignored?

when try use \verbass{halp} error: !file ended while scanning use of \@xverbatim.

obviously can use \begin{foo} ... \end{foo} @ locations needed, really, should work!

how \begin{verbatim} works. briefly , roughly.

  1. \begin{verbatim} expanded \verbatim.
  2. then \verbatim sets category code of each characters 11. chars letters.
  3. then \verbatim sets font, parindent , calls \@xverbatim.
  4. \@xverbatim catches end of verbatim using following trick:

    \def\@xverbatim#1\end{#1\end} 
  5. then \end{verbatim} finishes work.

how \newcommand{\verbass}[1]{\begin{verbatim} #1 \end {verbatim}} work.

  1. first of \verbass{halp} reads argument.
  2. #1 --> halp
  3. \verbass expands \begin{verbatim} halp \end {verbatim}. important: backslash of \end has category 0 rather 11. { , } have categories 1 , 2 rather 11.
  4. then \begin{verbatim} expands \varbatim. \varbatim changes categories , font. (important) category of backslash (in \end) remains equal 0.
  5. then \verbatim calls \@xverbatim.
  6. \@xverbatim tries catch argument using following trick:

    \def\@xverbatim#1\end{#1\end} 

    but impossible because of \@xverbatim tries catch \end letters (\,e,n,d) have category 11. in fact there 4 letters other category code: \ category 0 , e,n,d category 11.

  7. \@xverbatim trying , trying find \end backslash (\) has category 11 but.... file ended while scanning use of \@xverbatim

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -