# Getting negative vspace to behave

My TeX code (including parameters in command definitions) that creates lyrics sheets and chord sheets of songs is generated dynamically by other code accessing database data and processing it line by line, so my stripped-down MWE may seem odd, but bear with me.

The intent of the code snippet you see is that in addition to the basic line spacing associated with the two font sizes (which matters when lines wrap), an additional 0.3em is between each "paragraph" (line of lyrics) for clarity. However, whenever a line of romaji occurs immediately after a line of Japanese, I don't want that extra parskip, so I try to negate it with a \vspace of the negative of the same amount. So far, so good - the following file works:

\documentclass{ujarticle}
\usepackage[a4paper, margin=6mm]{geometry}
\usepackage{needspace}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\newcommand{\romaji}[1]{\begingroup\fontsize{10}{11.5}\selectfont
{#1}\endgroup}
\newenvironment{stanza}
{
\vspace{1em}
\setlength{\parskip}{0.3em}
\fontsize{12}{13.5}\selectfont
\begin{samepage}
}
{
\end{samepage}
}

\begin{document}
\sffamily
\gtfamily
\raggedright
\raggedbottom
\pagestyle{empty}

\begin{stanza}

\vspace{-0.3em}\nopagebreak
\romaji{sambi\ shite\ me\ o\ muketeru,\ anata\ ni\par}
\nopagebreak
もとめて待ち望んでる　あなたを\par
\vspace{-0.3em}\nopagebreak
\romaji{motomete\ machi\ nozonderu,\ anata\ o\par}
\end{stanza}

\end{document}


But when a style for romaji is added (in my test case, italic), it breaks and I get a huge hunk of extra space. The only difference between the left and right screenshots below is the addition of \textit{...} in the romaji command definition:

\newcommand{\romaji}[1]{\begingroup\fontsize{10}{11.5}\selectfont
\textit{{#1}}\endgroup}


Here is the output of the two:

mysterious spacing http://l4jp.com/tmp/TeX-tests.png

The complaint in the log file is:

Runaway argument?
{{sambi\ shite\ me\ o\ muketeru,\ anata\ ni !
Paragraph ended before \text@command was complete.


That makes sense, but I only get that error when the \textit{} is there - perhaps the parser can't navigate the double braces? Moving the \par after the closing brace makes the error go away, but then the \vspace is ignored in all cases.

• Have you tried \itshape instead of \textit? – erik Mar 24 '16 at 4:37
• ...use {\itshape ...} instead of \textit{...}. – Werner Mar 24 '16 at 4:57
• Yup, that works - thanks @erik and @Werner for the duet answer. So I guess you're saying that the way I'm doing the font size and \vspace and \par is not wrong (I thought I had bad form in there somewhere and the parser was just putting up with it), but I need to avoid using any styling inside the group that has "argument" syntax? – OsakaWebbie Mar 24 '16 at 21:35
• @erik An answer? – egreg Dec 3 '16 at 22:43

The problem lies in how you're telling \romaji to use italics. The command \textit{} expects an argument, thus cannot handle paragraph breaks. This is why it complains when it encounters \par. One option is to simply omit \par from the end of every \romaji command. Perhaps a better option is to use {\itshape …}, which applies to whatever follows and can handle paragraph breaks. See the following MWE for an example.

\documentclass{article}
\newcommand{\romaji}[1]{\begingroup\fontsize{10}{11.5}\selectfont{\itshape {#1}}\endgroup}
\begin{document}

\textit{sambi\ shite\ me\ o\ muketeru,\ anata\ ni}

{\itshape sambi\ shite\ me\ o\ muketeru,\ anata\ ni\par}

\romaji{sambi\ shite\ me\ o\ muketeru,\ anata\ ni\par}
\end{document}


• Thanks for making your comment into an answer so I can accept it, as well as a bit more explanation to help others who may come across this question. – OsakaWebbie Dec 4 '16 at 23:44