【问题标题】:Latex Multiple Linebreaks乳胶多个换行符
【发布时间】:2011-01-12 20:18:59
【问题描述】:

我使用 LaTeX 为课程输入编程作业。我需要这样做:

my line of text blah blah blah

new line of text with blank line between 

我知道我可以使用双斜杠来换行 \\,但是 LaTeX 只会使用第一个换行符(抱怨更多)并开始一个新行,它会产生这个:

my line of text blah blah blah  
new line of text with blank line between 

如何在其中获得额外的换行符,以便在文本行之间留出空格?

【问题讨论】:

标签: latex line-breaks


【解决方案1】:

插入一些垂直空间

blah blah blah \\
\vspace{1cm}

要缩放到字体,以ex(小写“x”的高度)为单位,还有与行距相关的various predefined lengths可用,你可能对baselineskip特别感兴趣。

【讨论】:

    【解决方案2】:

    您想要段落之间的更多空间吗?然后你可以更改参数\parskip

    例如,试试

    \setlength{\parskip}{10pt plus 1pt minus 1pt}
    

    这意味着段落之间的间距通常为 10pt,但最多可以增加或缩小 1pt。这意味着您让 LaTeX 能够将其更改为 1pt 以实现更好的页面布局。您可以删除加号和减号部分,使其始终为您指定的长度。

    如果您尝试显示源代码,请尝试使用listings 包或使用verbatim。如果您尝试排版伪代码,请尝试使用 algorithm 包。

    【讨论】:

      【解决方案3】:

      您可以使用setspace 包,它为您提供间距环境,例如:

      \documentclass{article}
      \usepackage{setspace}
      \begin{document}
      \doublespace
      my line of text blah blah blah
      
      new line of text with blank line between
      \end{document}
      

      或者使用verbatim 环境来精确控制代码的布局。

      【讨论】:

      • 对。如果这是编程作业,即源代码,请逐字逐句。
      【解决方案4】:

      换行符接受括号中的可选参数,垂直长度:

      line 1
      \\[4in]
      line 2
      

      要使其在字体大小方面更具可扩展性,您可以使用其他长度,例如 \\[3\baselineskip]\\[3ex]

      【讨论】:

      • 这是我需要的
      【解决方案5】:

      对于程序,你最好使用verbatimalltt 环境,但如果你想要一个LaTeX 不会抱怨的空行,试试

      my line of text blah blah blah\\
      \mbox{ }\\  %% space followed by newline
      new line of text with blank line between 
      

      【讨论】:

        【解决方案6】:

        虽然verbatim 可能是最佳选择,但您也可以尝试使用命令\smallskip\medskip 或猜猜看,\bigskip

        引用此page

        这些命令只能在 分段符(由 一个完全空白的行或由 命令\par)。这些命令输出 弹性或橡胶空间, 大约 3pt、6pt 和 12pt 高 分别,但这些命令将 自动压缩或扩展 位,根据需求而定 页面的其余部分

        【讨论】:

          【解决方案7】:

          我发现当我在 \\ 之后的源代码中包含一个空行时,我的输出中也会出现一个空行。示例:

          It's time to recognize the income tax as another horrible policy mistake like banning beer, and to return to the tax policies that were correct in the Constitution in the first place.  Our future depends on it.
          \\
          
          Wherefore the 16th Amendment must forthwith be repealed.
          

          但是你是正确的,LaTeX 只允许你这样做一次。对于更通用的解决方案,您可以根据需要创建尽可能多的空行,请使用 \null 来创建空段落。示例:

          It's time to recognize the income tax as another horrible policy mistake like banning beer, and to return to the tax policies that were correct in the Constitution in the first place.  Our future depends on it.
          
          \null
          
          \null
          
          \null
          
          Wherefore the 16th Amendment must forthwith be repealed.
          

          【讨论】:

            【解决方案8】:

            \\\\

            这适用于 pdfLatex。它会为您创建 2 个新行。

            【讨论】:

              【解决方案9】:

              也许尝试插入只有空格的行?

              \ \\
              \ \\
              

              【讨论】:

                【解决方案10】:

                这对我有用:

                我试图在 Apple Pages 的新 LaTeX 输入区域中留出空间。我输入了以下内容,它留下了一条干净的行。

                \mbox{\phantom{0}}\\

                【讨论】:

                • 请考虑添加 cmets,或者由于您的声誉较低,您将其作为答案是可以理解的,但如果您要添加答案,请尽量使其简短。谢谢。
                猜你喜欢
                • 2011-02-08
                • 1970-01-01
                • 2010-12-29
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 2019-02-24
                相关资源
                最近更新 更多