禁止显示列表中的第一个新行

禁止显示列表中的第一个新行

我想要进行以下类型的输入:

\newcommand{\test}[1]{\hangindent=2em\hangafter=0\noindent\raggedright\footnotesize{#1}\par\normalsize\vspace{1em}}

我想要条目包含列表并像这样创建它们:

\test{\MarginText{Some Margin Text A}Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor.
}

\test{\MarginText{Some Margin Text B}
\begin{itemize}
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor.
\end{itemize}
}

现在,例如 A,边距文本和 Lorem ipsum 水平对齐。例如 B,itemize 引入了换行符,这是不必要的,会破坏水平对齐。我尝试过 parsep 和 enumitem 包及其内联选项,但目前还没有结果。

结果

是否可以抑制这个换行符?

完整示例:

\documentclass{scrartcl}

\newcommand{\MarginText}[1]{\marginpar{\raggedleft\itshape\small#1}} % New command defining the margin text style
\reversemarginpar % Move the margin to the left of the page 


\newcommand{\test}[1]{\hangindent=2em\hangafter=0\noindent\raggedright\footnotesize{#1}\par\normalsize\vspace{1em}} % Define a command for descriptions of each entry - change spacing and font sizes here

\begin{document}

\test{\MarginText{Some Margin Text A}Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor.
}

\test{\MarginText{Some Margin Text B}
\begin{itemize}
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor.
\end{itemize}
}

\end{document}

答案1

两件事。首先,使用它,marginnote因为它效果更好。其次,搬到\MarginText{Some Margin Text B}室内\item

\item \MarginText{Some Margin Text B} Lorem ipsum ....

如果将其放在外面(如您所做的那样),则将其固定在上线。此外,\footnotesize{#1}应该是\footnotesize#1

完整代码:

\documentclass{scrartcl}
\usepackage{marginnote}

\newcommand{\MarginText}[1]{\marginnote{\raggedleft\itshape\small#1}} % New command defining the margin text style
\reversemarginpar % Move the margin to the left of the page


\newcommand{\test}[1]{\hangindent=2em\hangafter=0\noindent\raggedright\footnotesize#1\par\normalsize\vspace{1em}} % Define a command for descriptions of each entry - change spacing and font sizes here

\begin{document}

\test{\MarginText{Some Margin Text A}Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor.
}

\test{%
\begin{itemize}
\item \MarginText{Some Margin Text B} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor.
\end{itemize}
}

\end{document}

在此处输入图片描述

相关内容