DND-5e-LaTeX-Template icon indicating copy to clipboard operation
DND-5e-LaTeX-Template copied to clipboard

DndMonsterAttack does not support macros in attack modifier

Open rittermarc opened this issue 2 years ago • 1 comments

The \DndMonsterAttack macro breaks if macros such as \emph are used in the attack modifier.

I encountered this issue with an attack modifier that is dependent on a spell being active, in this case shillelagh. I tried to insert the following text:

+2 (+6 with shillelagh) to hit

using the following code:

\documentclass[letterpaper,twocolumn,openany,nodeprecatedcode]{dndbook}

\begin{document}
    \DndMonsterAttack[
        name=Club,
        mod=+2 (+6 with shillelagh),
        reach=5,
        dmg=\DndDice{1d4},
        dmg-type=bludgeoning,
        or-dmg=\DndDice{1d8+4},
        or-dmg-when=with \emph{shillelagh},
    ]
\end{document}

This breaks if you try to set shillelagh in cursive text using \emph{shillelagh} or \textit{shillelagh} in the mod parameter. If you try {\itshape shillelagh}, the latex code is set verbatim into the attack modifier (which surprised me quite a lot). Wrapping the text in braces does not help. As you can see, it does work fine in the or-dmg-when parameter.

Error messages:

.../dndmonster-mwe.tex:12: Argument of \reserved@a has an extra }.
<inserted text> 
                \par 
l.12     ]
          
Runaway argument?
{\unexpanded {shillelagh}}\ifx \reserved@a \@empty \let \check@icl \@empty \ETC.
.../dndmonster-mwe.tex:12: Paragraph ended before \reserved@a was complete.
<to be read again> 
                   \par 
l.12     ]
          
.../dndmonster-mwe.tex:12: Undefined control sequence.
\reserved@a ->\@nil 
                    
l.12     ]
          
.../dndmonster-mwe.tex:12: Undefined control sequence.
\reserved@a ->\@nil 
                    
l.12     ]
          
.../dndmonster-mwe.tex:12: Undefined control sequence.
\reserved@a ->\@nil 
                    
l.12     ]
          
.../dndmonster-mwe.tex:12: Undefined control sequence.
\reserved@a ->\@nil 
                    
l.12     ]
          
.../dndmonster-mwe.tex:12: Undefined control sequence.
\reserved@a ->\@nil 
                    
l.12     ]
          
.../dndmonster-mwe.tex:12: Undefined control sequence.
\reserved@a ->\@nil 
                    
l.12     ]
          
.../dndmonster-mwe.tex:12: Undefined control sequence.
\reserved@a ->\@nil 
                    
l.12     ]
          
.../dndmonster-mwe.tex:12: Undefined control sequence.
\reserved@a ->\@nil 
                    
l.12     ]

This is my first time opening an issue, so apologies if I did anything wrong.

rittermarc avatar Jun 06 '22 11:06 rittermarc

Try surrounding the entirety of the argument (everything after "mod=") in curly braces. If that doesn't work, please post an MWE.

BrianCriswell avatar Jun 08 '22 06:06 BrianCriswell