如何在单词上方、两行文本之间插入段落

如何在单词上方、两行文本之间插入段落

我正在尝试在一段文本中添加行间注释。我目前使用的解决方案如下:如何在 LaTeX 中实现文本居中

这涉及定义命令

\newcommand\wrd[2]{%
  \leavevmode
  \vbox{\offinterlineskip
    \halign{%
      \hfil##\hfil\cr
      {\footnotesize\sffamily\vphantom{p}#1}\cr
      \noalign{\vskip\lineskip}%
      \vphantom{A}#2\cr
    }%
  }%
}

并运行

\wrd{Tang Yin is a painter, poet and calligrapher, one of the "Four Masters of Ming Dynasty.}{Tang Yin entitled ‘Spring Slumber’ depicting a beautiful woman asleep.}

但是,当我的评论超过一行时,我就会遇到麻烦。理想情况下,我希望评论(即使有多行)完全位于它所评论的文本行上方。我尝试过使用 expex,但我对 LaTeX 不太熟悉,不知道如何完成这个简单的任务。请有人帮帮我。

我的问题

编辑:这是一个可编译的小例子:

\documentclass[twoside,11pt]{memoir} % Font size

\usepackage{expex}


\newcommand\wrd[2]{%
  \leavevmode
  \vbox{\offinterlineskip
    \halign{%
      \hfil##\hfil\cr
      {\footnotesize\sffamily\vphantom{p}#1}\cr
      \noalign{\vskip\lineskip}%
      \vphantom{A}#2\cr
    }%
  }%
}
%----------------------------------------------------------------------------------------

\begin{document}


\lq What a lovely smell!\rq



He repeated the words several times over.
    Inside the room there was a painting \wrd{This is an interlinear comment but it is too long to fit above the line}. {by Tang Yin entitled ‘Spring Slumber’ depicting a beautiful woman asleep. under a crab-apple tree}, whose buds had not yet opened. The painting was flanked on either side by a pair of calligraphic scrolls inscribed with a couplet from the brush of the Song poet Qin Guan:
    
    (on one side)
    \vskip5pt
    
    
\end{document}

答案1

目前还不清楚所需的格式,但我在这里引入了\longnote{width}{content}。我在文本中调用它的位置插入了一个红色的小向上箭头。方法是将 顶搭接\parbox

\documentclass{article}
\usepackage{stackengine,xcolor}
\newcommand\longnote[2]{%
  \makebox[0pt]{\textcolor{red}{$^{\uparrow}$}}%
  \tclap{\parbox[b]{#1}{\footnotesize\sffamily\strut#2}}%
}

\begin{document}
However, I run into trouble when my comment is more than one line long. Ideally, I would like the comment, even if it is multiple lines, to exist entirely above the line of text it is commenting on. I have tried to use expex, but I am not familiar enough with LaTeX generally to know how to do this simple task. Someone please help me.
However, I run\longnote{3in}{%
This is top-lapped text.  We will see if the text is long enough if the
  lines make space for more text.
This is top-lapped text.  We will see if the text is long enough if the
  lines make space for more text.
This is top-lapped text.  We will see if the text is long enough if the
  lines make space for more text.
}
into trouble when my comment is more than one line long. Ideally, I would like the comment, even if it is multiple lines, to exist entirely above the line of text it is commenting on. I have tried to use expex, but I am not familiar enough with LaTeX generally to know how to do this simple task. Someone please help me.
\end{document}

在此处输入图片描述


补充

根据 OP 的评论,我在下面提供了一个替代方案。首先,我删除了 中的\sffamily\longnote以便注释仍然使用当前文档字体系列(在本例中为罗马字体)排版。此外,我选择在此处固定注释的宽度(3 英寸),这\longnote在之前的实现中是 的第一个参数。在这里,我将第一个参数(现在是可选的)设为顶部搭接的位置说明符,可以是[l](left)、[c](center-default) 或[r](right)。虽然让宏知道它在文本行的哪个位置被调用是理想的(但它不知道),但此选项将允许用户事后避免左/右边距超出范围。

\documentclass{article}
\usepackage{stackengine,xcolor}
\newcommand\longnote[2][c]{%
  \makebox[0pt]{\textcolor{red}{$^{\uparrow}$}}%
  \toplap{#1}{\parbox[b]{3in}{\footnotesize\strut#2}}%
}

\begin{document}
However, I run into trouble when my comment is more than one line long. Ideally, I would like the comment, even if it is multiple lines, to exist entirely above the line of text it is commenting on. I have tried to use expex, but I am not familiar enough with LaTeX generally to know how to do this simple task. Someone\longnote[r]{%
This is top-lapped text.  We will see if the text is long enough if the
  lines make space for more text.
This is top-lapped text.  We will see if the text is long enough if the
  lines make space for more text.
}
please help me.
However, I run into trouble when my comment is more than one line long. Ideally, I would like the comment, even if it is multiple lines, to exist entirely above the line of text it is commenting on. 
I have tried to\longnote[l]{%
This is top-lapped text.  We will see if the text is long enough if the
  lines make space for more text.
}
 use expex, but I am not familiar enough with LaTeX generally to know how to do this simple task. Someone please help me.
\end{document}

在此处输入图片描述

相关内容