![\MacroFont](https://linux22.com/image/373721/%5CMacroFont.png)
MWE 显示了我的意思。使用 class article 我可以更改逐字字体。使用 ltxdoc 没有任何反应。我查看了 doc.sty 和 ltxdoc.cls,但什么也没找到。为什么逐字环境字体设置在 ltxdoc 中的行为不同?
%\documentclass[a4paper,12pt]{article}
\documentclass[a4paper,12pt]{ltxdoc}
\makeatletter
\newcommand{\verbatimfont}[1]{\def\verbatim@font{#1}}%
\makeatother
\verbatimfont{\normalfont\rmfamily\Large}
\begin{document}
This is normal text
\begin{verbatim}
This is verbatim text
\end{verbatim}
\end{document}
答案1
答案2
\MacroFont
也许,您正在寻找\MacroFont
的包doc
(默认字体大小由 定义\MacroFont
)\small
:
\documentclass[a4paper,12pt]{ltxdoc}
\makeatletter
\g@addto@macro\MacroFont{\Large}
\g@addto@macro\AltMacroFont{\Large}% slanted verbatim
\makeatother
\begin{document}
This is normal text
\begin{verbatim}
This is verbatim text
\end{verbatim}
\end{document}
\MacroFont
用于环境verbatim
、、、和宏、、、和。verbatim*
macrocode
\PrintMacroName
\PrintDescribeMacro
\PrintDescribeEnv
\PrintEnvName
修补verbatim
另一个解决方案是修补环境verbatim
。以下示例显示了它对verbatim
和的修补verbatim*
:
\documentclass[a4paper,12pt]{ltxdoc}
\usepackage{etoolbox}
\patchcmd\verbatim{\MacroFont}{\MacroFont\Large}{}{%
\errmessage{Cannot patch enviroment `verbatim'.}%
}
\expandafter
\patchcmd\csname verbatim*\endcsname{\MacroFont}{\MacroFont\Large}{}{%
\errmessage{Cannot patch environment `verbatim*'.}%
}
\begin{document}
This is normal text
\begin{verbatim}
This is verbatim text
\end{verbatim}
\end{document}
答案3
我找到了一个简单的解决方案,如下所示。现在只有verbatim
环境受到影响。
\documentclass[a4paper,12pt]{ltxdoc}
\begin{document}
This is normal text
{
\renewcommand{\MacroFont}{\ttfamily\large}
\begin{verbatim}
This is verbatim text
\end{verbatim}
}
\end{document}