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

I'm trying to make Latex usable by introducing a few time options, but I'm having trouble defining new commands that interrupt the environment, completely at random.

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

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

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

In particular, I think the \ end value is simply ignored?

When I try to use \verbass{Halp}, I get an error message:!File ended while scanning use of \@xverbatim.

Obviously, I can use \ begin {foo} ... \ end {foo} in all places as needed, but it should actually work!

+3
source share
3 answers

How does it work \begin{verbatim}. briefly and rudely.

  • \begin{verbatim}expands to \verbatim.
  • \verbatim 11. - .
  • \verbatim , parindent \@xverbatim.
  • \@xverbatim , :

    \def\@xverbatim#1\end{#1\end}
    
  • \end {verbatim} .

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

  • \verbass{Halp} .
  • #1 --> Halp
  • \verbass \begin{verbatim} Halp \end {verbatim}.   : \end 0, 11.   , { } 1 2, 11.
  • \begin{verbatim} \varbatim.  \varbatim . ()   ( \end) 0.
  • \verbatim \@xverbatim.
  • \@xverbatim , :

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

    , \@xverbatim \end, (\, e, n, d) 11. : \ 0 e, n, d 11.

  • \@xverbatim \end, (\) 11, .... File ended while scanning use of \@xverbatim
+5

. , LaTeX "" .

0

, :

\newcommand{\myverbatim}[1]{\begin{tt} \detokenize{#1} \end{tt} \\ }

, - . , (?).

-1

Source: https://habr.com/ru/post/1768464/


All Articles