好的,这里有一些代码可以展示我遇到的问题:
\documentclass[10pt,letterpaper]{article}
\usepackage{expex}
\newcommand{\gloss}[3]{\ex[numoffset=2em,aboveglftskip=0pt]
\begingl
\gla #1//
\glb #2//
\glft #3//
\endgl
\xe}
\begin{document}
\gloss123
blahblahblahblahblahblahblahblahblahblahblahblahblah
\ex[numoffset=2em,aboveglftskip=0pt]
\begingl
\gla 1//
\glb 2//
\glft 3//
\endgl
\xe
blahblahblahblahblahblahblahblahblahblahblahblahblah
\end{document}
如您所见,第一个注释和 blah 之间有额外的垂直空间。如何在仍使用 \newcommand 的情况下消除此问题?
答案1
这是因为\gloss{.}{.}{.}
在输入流中留下了虚假的空间。您可以通过%
在末尾放置一个或在\ignorespaces
定义末尾添加来避免这种情况\newcommand
:
\documentclass{article}
\usepackage{expex}
\newcommand{\gloss}[3]{\ex[numoffset=2em,aboveglftskip=0pt]
\begingl
\gla #1//
\glb #2//
\glft #3//
\endgl
\xe
\ignorespaces}
\begin{document}
\gloss{1}{2}{3}%
blahblahblahblahblahblahblahblahblahblahblahblahblah
\ex[numoffset=2em,aboveglftskip=0pt]
\begingl
\gla 1//
\glb 2//
\glft 3//
\endgl
\xe
blahblahblahblahblahblahblahblahblahblahblahblahblah
\end{document}
答案2
\vspace{-\baselineskip}}
我不知道为什么会发生这种情况,但我们可以在命令末尾添加负垂直空间来解决这个问题。
\documentclass[10pt,letterpaper]{article}
\usepackage{expex}
\newcommand{\gloss}[3]{\ex[numoffset=2em,aboveglftskip=0pt]
\begingl
\gla #1//
\glb #2//
\glft #3//
\endgl
\xe
\vspace{-\baselineskip}
}
\begin{document}
\gloss123
blahblahblahblahblahblahblahblahblahblahblahblahblah
\ex[numoffset=2em,aboveglftskip=0pt]
\begingl
\gla 1//
\glb 2//
\glft 3//
\endgl
\xe
blahblahblahblahblahblahblahblahblahblahblahblahblah
\end{document}