0

I would like to improve the new commands in my listing, especially the \did command. Do I have to use within it an arguments #1 and \def\? Thank you.

\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
  • Thank you for your response. I modified the \as command as you recommended. For the \did command, I would like it to remain "detached" from the text, without including the argument in {}, as in the example. I'm wrong?
    – Andy Toff
    Commented Mar 16, 2022 at 9:15

1 Answer 1

2

enter image description here

I would use standard LaTeX syntax here, both for the definition (so no \def) and for the document command (an environment not a \par delimited macro). Also keeping \large local to the did text, and not adding a space after \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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .