TransWikia.com

New command to turn to italics

TeX - LaTeX Asked by Andy Toff on December 31, 2020

I’d like to create a command that will turn all of the text that follows into italics, but something isn’t working.
Where am I going wrong?

p.s.: I know I could do it differently, but it’s important that it’s really a command!

documentclass[a4paper,11pt,draft]{report}
usepackage[utf8]{inputenc}

newcommandTom{parbigskipnoindenthbox to35mm{Tomhfil}hangindent=35mm }
newcommandMary{parbigskipnoindenthbox to35mm{Maryhfil}hangindent=35mm }
newcommandaction{parbigskipnoindentitshape}

begin{document}

Tom
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum is simply dummy text of the printing and typesetting industry.

action
This is the action line to put into the new text

Mary
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum is simply dummy text of the printing and typesetting industry.
    
end{document}

enter image description here

One Answer

So long as you always follow the action directive with a blank line, you can do

newcommand{action}{} % to avoid overwriting an existing command
defaction#1par{parbigskipnoindenttextit{#1}par}

Full example with other fixes:

documentclass[a4paper,11pt,draft]{report}

newcommandTom{parbigskipnoindentmakebox[35mm][l]{Tom}hangindent=35mm }
newcommandMary{parbigskipnoindentmakebox[35mm][l]{Mary}hangindent=35mm }
newcommandaction{}
defaction#1par{parbigskipnoindenttextit{#1}par}

begin{document}

Tom
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum is simply dummy text of the printing and typesetting industry.

action
This is the action line to put into the new text

Mary
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum is simply dummy text of the printing and typesetting industry.
    
end{document}

enter image description here

Alternative, but action<text> must be followed either by a blank line or one among Tom or Mary.

documentclass[a4paper,11pt,draft]{report}

newcommandTom{%
  parbigskipnoindentmakebox[35mm][l]{Tom}hangindent=35mm
}
newcommandMary{%
  parbigskipnoindentmakebox[35mm][l]{Mary}hangindent=35mm
}
makeatletter
newcommandaction{%
  begingroup
  parbigskipnoindentitshape
  defpar{endgroup@@par}%
}
makeatother

begin{document}

Tom
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum is simply dummy text of the printing and typesetting industry.

action
This is the action line to put into the new text
Mary
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum is simply dummy text of the printing and typesetting industry.
    
end{document}

Correct answer by egreg on December 31, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP