根据问题如何重命名或“复制”乳胶环境我尝试将comment
环境重命名为myenvironment
:
\documentclass[10pt,a5paper,twoside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage[showframe,pass]{geometry}
\usepackage{comment}
\makeatletter
% \newenvironment{myenvironment}{\comment}{\endcomment}
\let\myenvironment\comment
\let\endmyenvironment\endcomment
\makeatother
\begin{document}
This is normal text.
\begin{myenvironment}
How to make this environment be \bfseries{verbatim}?
\end{myenvironment}
\end{document}
但是它会出现错误:
Excluding 'comment' comment.)
Runaway argument?
! File ended while scanning use of \next.
<inserted text>
\par
<*> ./test2.tex
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.
! Emergency stop.
<*> ./test2.tex
答案1
问题代码测试得很差:
comment
可以通过使用宏创建新的环境版本来“重命名”环境\excludecomment{myenvironment}
- 环境
verbatim
正确接受并重命名\let\myotherenvironment\verbatim
为\let\endmyotherenvironment\endverbatim
:
例子:
\documentclass[10pt,a5paper,twoside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage[showframe,pass]{geometry}
\usepackage{lmodern}
\usepackage{comment}
% How to rename an existing command?
% https://tex.stackexchange.com/questions/193379/how-to-rename-an-existing-command
\newcommand{\supertiny}{\fontsize{2pt}{2.5pt}\selectfont}
\excludecomment{myenvironment}
\newenvironment{myotherenvironment}{\verbatim\supertiny}{\normalfont\endverbatim}
\begin{document}
This is normal text.
\begin{myenvironment}
How to make this environment be a comment?
\end{myenvironment}
\begin{myotherenvironment}
How to make this environment be {\bfseries verbatim}?
\end{myotherenvironment}
\end{document}