让Latex遵守换行符

6
有没有LaTeX中的环境可以实现这个功能?
Feb 22 06:00AM - Wake up
Feb 22 06:15AM - Have breakfast
Feb 22 08:00AM - A very long sentence that I will have to break at some point
                 but maintaining indentation
Feb 22 08:00AM - Or maybe just a list here
                 One
                 Two
                 Three

我不想使用Verbatim,而且每个句子都以\\结尾也不能保留缩进格式。有没有简单的方法可以实现这一点,还是我必须手动调整它?


@rlibby 是的,我当时想得不对 :) 离开LaTeX太久了。 - user525602
顺便提一下 -- 你在 tex.stackexchange.com 上可能会得到更好的LaTeX答案(这并不意味着在这里发布有什么问题)。 - dmckee --- ex-moderator kitten
4个回答

2

我建议使用tabularx包。与普通的tabular环境不同,这将让LaTeX自动断开长行。

\documentclass{article}
\usepackage{tabularx}

\begin{document}
\begin{tabularx}{\columnwidth}{rX}
Feb 22 06:00AM -& Wake up \\
Feb 22 06:15AM -& Have breakfast \\
Feb 22 08:00AM -& A very long sentence that I will have to break at some point
                  but maintaining indentation \\
Feb 22 08:00AM -& Or maybe just a list here
                  One
                  Two
                  Three
\end{tabularx}
\end{document}

如果你想手动插入换行,那很简单:

Feb 22 08:00AM -& Or maybe just a list here \\
                & One \\
                & Two \\
                & Three

更多信息:


0

目前我发现最好的方法是使用org-mode(因为这是我生成LaTeX的方式),并使用orgmode表格。

| Feb 22 06:00AM - | Wake up                                                                                  |
| Feb 22 06:15AM - | Have breakfast                                                                           |
| Feb 22 08:00AM - | A very long sentence that I will have to break at some point but maintaining indentation |
|                  | Or maybe just a list here                                                                |
|                  | One                                                                                      |
|                  | Two                                                                                      |
|                  | Three                                                                                    |

然后它将被导出为一个表格环境,就像这样:

\begin{tabular}{ll}
 Feb 22 06:00AM -  &  Wake up                                                                                   \\
 Feb 22 06:15AM -  &  Have breakfast                                                                            \\
 Feb 22 08:00AM -  &  A very long sentence that I will have to break at some point but maintaining indentation  \\
                   &  Or maybe just a list here                                                                 \\
                   &  One                                                                                       \\
                   &  Two                                                                                       \\
                   &  Three                                                                                     \\
\end{tabular}

0

将parindent设置为负值,并将每个项目视为段落:

\documentclass{article}
\parindent -4em
\begin{document}
Feb 22 06:00AM - Wake up

Feb 22 06:15AM - Have breakfast

Feb 22 08:00AM - A very long sentence that I will have to break at some point but maintaining indentation

Feb 22 08:00AM - Or maybe just a list here\\
             One\\
             Two\\
             Three\\
\end{document}

0
也许我在之前的回答中误解了你的问题。如果你想要缩进量自动调整为最长标签,请使用itemize:
\documentclass{article}
\begin{document}
\begin{itemize}
\item[Feb 22 06:00AM -] Wake up
\item[Feb 22 06:15AM -] Have breakfast
\item[Feb 22 08:00AM -] A very long sentence that I will have to break at some point but maintaining indentation
\item[Feb 22 08:00AM -] Or maybe just a list here\\
             One\\
             Two\\
             Three\\
\end{itemize}
\end{document}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接