使用 \marginpar 开始新段落并正确对齐

使用 \marginpar 开始新段落并正确对齐

我正在尝试定义一个类似的命令,\introduce{...}将其内容打印到边缘。

我心想“简单”,就这么做\newcommand{\introduce}[1]{\marginpar{#1}#1}

我把#1它放在后面的理由\marginpar{#1}是,在第一个单词的行中开始 maringpar,否则,如果较长的内容只有最后一个单词流到下一行,看起来会很奇怪。

然而,我注意到,当一个段落的第一个单词以这种方式突出显示时,marginpar 与前一行对齐。

有没有简单的方法可以解决这个问题?

平均能量损失

\documentclass[a4paper,11pt]{scrartcl}
\usepackage[utf8]{inputenc}
\newcommand{\introduce}[1]{\marginpar{#1}\emph{#1}} % too high
% \newcommand{\introduce}[1]{\emph{#1}\marginpar{#1}} % too low

\begin{document}

Bacon ipsum dolour sit amet porchetta beef turkey, bacon turducken boudin hamburger venison ball tip. Brisket pork loin bresaola short loin ground round leberkas pastrami tongue jerky cow turducken beef ribs. Pork ribeye landjaeger prosciutto pig venison tenderloin. Swine beef ribs kielbasa, porchetta tenderloin salami venison pork belly tail.

\introduce{More Bacon} ipsum dolour sit amet porchetta beef turkey, bacon turducken boudin hamburger venison ball tip. Brisket pork loin bresaola short loin ground round leberkas pastrami tongue jerky cow turducken beef ribs. Pork ribeye landjaeger prosciutto pig venison tenderloin. Swine beef ribs kielbasa, porchetta tenderloin salami venison pork belly tail.

Ipsum dolour sit amet porchetta beef turkey, bacon turducken boudin hamburger \introduce{even more Bacon} venison ball tip. Brisket pork loin bresaola short loin ground round leberkas pastrami tongue jerky cow turducken beef ribs. Pork ribeye landjaeger prosciutto pig venison tenderloin. Swine beef ribs kielbasa, porchetta tenderloin salami venison pork belly tail.

\end{document}

太高:

太高

太低:

太低

答案1

添加\leavevmode以便无论如何该段落都会开始。

\documentclass[a4paper,11pt]{scrartcl}
\usepackage[utf8]{inputenc}

\newcommand{\introduce}[1]{%
  \leavevmode % if at the start of a paragraph 
  \marginpar{#1}% the note
  \emph{#1}% the text
}

\begin{document}

Bacon ipsum dolour sit amet porchetta beef turkey, bacon turducken 
boudin hamburger venison ball tip. Brisket pork loin bresaola short 
loin ground round leberkas pastrami tongue jerky cow turducken beef 
ribs. Pork ribeye landjaeger prosciutto pig venison tenderloin. 
Swine beef ribs kielbasa, porchetta tenderloin salami venison pork 
belly tail.

\introduce{More Bacon} ipsum dolour sit amet porchetta beef turkey, 
bacon turducken boudin hamburger venison ball tip. Brisket pork loin 
bresaola short loin ground round leberkas pastrami tongue jerky cow 
turducken beef ribs. Pork ribeye landjaeger prosciutto pig venison 
tenderloin. Swine beef ribs kielbasa, porchetta tenderloin salami 
venison pork belly tail.

Ipsum dolour sit amet porchetta beef turkey, bacon turducken boudin 
hamburger \introduce{even more Bacon} venison ball tip. Brisket pork 
loin bresaola short loin ground round leberkas pastrami tongue jerky 
cow turducken beef ribs. Pork ribeye landjaeger prosciutto pig venison 
tenderloin. Swine beef ribs kielbasa, porchetta tenderloin salami 
venison pork belly tail.

\end{document}

在此处输入图片描述

答案2

\documentclass[a4paper,11pt]{scrartcl}
\usepackage[utf8]{inputenc}

\newcommand{\introduce}[1]{\mbox{}\marginpar{#1}\emph{#1}}

\begin{document}

Bacon ipsum dolour sit amet porchetta beef turkey, bacon turducken boudin hamburger venison ball tip. Brisket pork loin bresaola short loin ground round leberkas pastrami tongue jerky cow turducken beef ribs. Pork ribeye landjaeger prosciutto pig venison tenderloin. Swine beef ribs kielbasa, porchetta tenderloin salami venison pork belly tail.

\introduce{More Bacon} ipsum dolour sit amet porchetta beef turkey, bacon turducken boudin hamburger venison ball tip. Brisket pork loin bresaola short loin ground round leberkas pastrami tongue jerky cow turducken beef ribs. Pork ribeye landjaeger prosciutto pig venison tenderloin. Swine beef ribs kielbasa, porchetta tenderloin salami venison pork belly tail.

Ipsum dolour sit amet porchetta beef turkey, bacon turducken boudin hamburger \introduce{even more Bacon} venison ball tip. Brisket pork loin bresaola short loin ground round leberkas pastrami tongue jerky cow turducken beef ribs. Pork ribeye landjaeger prosciutto pig venison tenderloin. Swine beef ribs kielbasa, porchetta tenderloin salami venison pork belly tail.

\end{document}

在此处输入图片描述

相关内容