如何仅在右侧写部分文字?

如何仅在右侧写部分文字?

我希望得到一些帮助,以便能够以如下图所示的形式在右侧完整地编写一段文本。非常感谢! 在此处输入图片描述

答案1

\documentclass{article}
\usepackage{tabularx}
\begin{document}

\begin{tabularx}{\linewidth}{lX}
Some text here:&
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  Donec
  hendrerit tempor tellus.  Donec pretium posuere tellus.  Proin quam
  nisl, tincidunt et, mattis eget, convallis nec, purus.  Cum sociis
  natoque penatibus et magnis dis parturient montes, nascetur
  ridiculus mus.  Nulla posuere. \\ \vspace{2ex}

Some other text here :&
    Pellentesque dapibus suscipit ligula.  Donec posuere augue in
    quam.  Etiam vel tortor sodales tellus ultricies commodo.
    Suspendisse potenti.  Aenean in sem ac leo mollis blandit.  Donec
    neque quam, dignissim in, mollis nec, sagittis eu, wisi.
    Phasellus lacus. 
  \end{tabularx}

  \begin{tabularx}{\linewidth}{lX}
Some text:&
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  Donec
  hendrerit tempor tellus.  Donec pretium posuere tellus.  Proin quam
  nisl, tincidunt et, mattis eget, convallis nec, purus.  Cum sociis
  natoque penatibus et magnis dis parturient montes, nascetur
  ridiculus mus.  Nulla posuere.  Donec vitae dolor.  Nullam tristique
  diam non turpis.  Cras placerat accumsan nulla.  Nullam rutrum.  Nam
  vestibulum accumsan nisl.\vspace{2ex}
  \end{tabularx}

\end{document}

文本

答案2

您可以在使用\hagindent原语\hangafter测量文本后使用 TeX 原语\setbox

\def\p #1: {\par \setbox0=\hbox{#1: }\hangafter=1\hangindent=\wd0 \noindent\box0 }

\p Sometext here: bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
                  bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
                  bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
                  bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla.

答案3

以下方法使用paracol设置两列环境,其中左列仅包含标题。

在此处输入图片描述

\documentclass{article}

\usepackage{paracol,lipsum}

\newlength{\sometextheading}
\newenvironment{sometext}[1]{%
  \settowidth{\sometextheading}{#1:}%
  \setcolumnwidth{\sometextheading}%
  \par
  \begin{paracol}{2}
    \noindent #1:
    \switchcolumn[1]\noindent\ignorespaces
}{%
  \end{paracol}
}

\begin{document}

\sloppy% Just for this example
Here is some text

\begin{sometext}{Some text}
  \lipsum[1]
\end{sometext}

\begin{sometext}{Some more text here}
  \lipsum[2]
\end{sometext}

\begin{sometext}{Yet more text}
  \lipsum[3-6]
\end{sometext}

\begin{sometext}{Some closing text}
  \lipsum[7]
\end{sometext}

\end{document}

答案4

这是一个非常简单的解决方案:使用itemize左侧文本作为自定义“项目符号”。这不需要任何包或大量代码,并且会使所有右侧文本对齐。

\documentclass{article}
\begin{document}

\begin{itemize}
 \item[Some text here:] Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  Donec hendrerit tempor tellus.  Donec pretium posuere tellus.  Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus.  Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.  Nulla posuere. \\ \vspace{2ex}
 \item[Some other text here:] Pellentesque dapibus suscipit ligula.  Donec posuere augue in quam.  Etiam vel tortor sodales tellus ultricies commodo. Suspendisse potenti.  Aenean in sem ac leo mollis blandit.  Donec neque quam, dignissim in, mollis nec, sagittis eu, wisi.  Phasellus lacus. 
\end{itemize}
 
\end{document}

输出

相关内容