水平对齐(缩进)列表和段落

水平对齐(缩进)列表和段落

我正在寻找一种按以下方式缩进文本的方法:

Section Name: Lorem ipsum dolor sit amet, consectetur adipiscing elit,
              sed do eiusmod tempor incididunt ut labore et dolore
              magna aliqua.
              Ut enim ad minim veniam, quis nostrud exercitation
              ullamco laboris nisi ut aliquip ex ea commodo consequat.
Another Section: Duis aute irure dolor in reprehenderit in voluptate
                 velit esse cillum dolore eu fugiat nulla pariatur.

我不太确定我该如何做这件事,有人有什么建议吗?

谢谢!

答案1

您可以使用该hang包;它提供了两种可能的解决方案。

\documentclass{article}
\usepackage{hang}

\usepackage{lipsum} % just for the example

\newenvironment{tobihang}[1]
 {\begin{labeledpar}{#1: \hspace{-1em}}{#1: \hspace{-1em}}\ignorespaces}
 {\end{labeledpar}}

\newenvironment{tobihangspaced}[1]
 {\begin{labeledlist}{#1: \hspace{-1em}}\item[#1: \hspace{-1em}]\ignorespaces}
 {\end{labeledlist}}

\begin{document}

\lipsum[2]

\begin{tobihang}{Section Name}
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{tobihang}

\begin{tobihang}{Another Section}
Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur.
\end{tobihang}

\begin{tobihangspaced}{Section Name}
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{tobihangspaced}

\begin{tobihangspaced}{Another Section}
Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur.
\end{tobihangspaced}

\end{document}

在此处输入图片描述

我们需要明确,-1em因为hang硬连线\labelsep=1em

相关内容