我想改进列表中的新命令,尤其是\did
命令。我必须在其中使用参数#1
和吗\def\
?谢谢。
\documentclass[a4paper,12pt]{article}
\usepackage{xcolor}
\newcommand\as[1]{\color{red}\textsl{#1 }\color{black}}
\newcommand\did{}\def\did#1\par{\large\par\vspace{5mm}\noindent\textsl{#1}\par}
\begin{document}
\did
This text must be spaced 5mm apart at the top and must be
italicized throughout its length.
This text, on the other hand,
is normal \as{(it should become italicized and red here)}.
Here it should go back to normal and black.
\end{document}
答案1
我会在这里使用标准 LaTeX 语法,既用于定义(所以没有\def
),也用于文档命令(环境而不是\par
分隔的宏)。同时保持文本\large
的本地化did
,并且不在后面添加空格\as{...}
\documentclass[a4paper,12pt]{article}
\usepackage{xcolor}
%using tex grouping (and no extra space
\newcommand\as[1]{\textsl{\color{red}#1}}
% using an environment, keeping the size change just to the did text,
% not the rest of the document,
\newenvironment{did}
{\par\setlength\parindent{0pt}\large\vspace{5mm}\slshape}
{\par}
\begin{document}
Earlier text.
\begin{did}
This text must be spaced 5mm apart at the top and must be
italicized(or rather slanted) throughout its length.
\end{did}
This text, on the other hand,
is normal \as{(it should become italicized (acually slanted)and red here)}.
Here it should go back to normal and black.
\end{document}