将右对齐段落进一步移至中心

将右对齐段落进一步移至中心

所以我正在为我们的圣诞聚会排版一本小歌本。为了更好地利用有限的空间,我使用了包装multicol;这没什么问题。

我想做的是将整个段落水平移动任意大小的空间。在下面的 MWE 中,我们来看看第 3 节。它使用环境\begin{flushright},但我仍然想将其稍微移到中心,保持右边缘整齐对齐。

\documentclass[fontsize=12pt,paper=A5,DIV=14,headinclude=true,footinclude=true,headings=small,pagesize,parskip=half]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,naustrian]{babel}
\usepackage[babel=true,protrusion=true,factor=900,draft=false]{microtype}

\usepackage{multicol, sectsty}

\raggedbottom
\addtolength{\topmargin}{-1cm}
\addtolength{\textheight}{2.5cm}
\allsectionsfont{\large\centering}

\begin{document}
    \section{The Little Drummer Boy}
        \begin{multicols}{2}

            1. Come, they told me,\\ 
            \emph{pa rum pum pum pum},\\
            our new born King to see, \\
            \emph{pa rum pum pum pum},\\
            our finest gifts we'll bring, \\
            \emph{pa rum pum pum pum},\\
            to lay before the King, \\
            \emph{pa rum pum pum pum},\\
            \emph{rum pum pum pum,\\ rum pum pum pum.}

            So to honor Him,\\ 
            \emph{pa rum pum pum pum},\\
            when we come.

        \columnbreak

            2. Little Baby, \\
            \emph{pa rum pum pum pum},\\
            I am a poor boy, too,\\
            \emph{pa rum pum pum pum},\\
            I have no gift to bring,\\
            \emph{pa rum pum pum pum},\\
            that's fit to give a King,\\
            \emph{pa rum pum pum pum},\\
            \emph{rum pum pum pum,\\ rum pum pum pum}

            Shall I play for you,\\
            \emph{pa rum pum pum pum},\\
            on my drum? 

    \end{multicols}
    \begin{flushright}

            3. Mary nodded, \emph{pa rum pum pum pum},\\
            the ox and lamb kept time, \emph{pa rum pum pum pum},\\
            I played my drum for Him, \emph{pa rum pum pum pum},\\
            I played my best for Him, \emph{pa rum pum pum pum},\\
            rum pum pum pum, rum pum pum pum.

            Then He smiled at me, \emph{pa rum pum pum pum},\\
            me and my drum.

    \end{flushright}
\end{document}

在此处输入图片描述

答案1

您只需\rightskipflushright. 中指定不同的值flushright,方法是将\rightskip0pt添加\leftskip到 可扩展胶合中。\rightskip用某个正长度替换该值,例如

\begin{flushright}%
  \setlength{\rightskip}{3em}%
  ...
\end{flushright}

示例输出

\documentclass[fontsize=12pt,paper=A5,DIV=14,headinclude=true,footinclude=true,headings=small,pagesize,parskip=half]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,naustrian]{babel}

\usepackage{multicol, sectsty}

\raggedbottom
\addtolength{\topmargin}{-1cm}
\addtolength{\textheight}{2.5cm}
\allsectionsfont{\large\centering}

\begin{document}
    \section{The Little Drummer Boy}
        \begin{multicols}{2}

            1. Come, they told me,\\ 
            \emph{pa rum pum pum pum},\\
            our new born King to see, \\
            \emph{pa rum pum pum pum},\\
            our finest gifts we'll bring, \\
            \emph{pa rum pum pum pum},\\
            to lay before the King, \\
            \emph{pa rum pum pum pum},\\
            \emph{rum pum pum pum,\\ rum pum pum pum.}

            So to honor Him,\\ 
            \emph{pa rum pum pum pum},\\
            when we come.

        \columnbreak

            2. Little Baby, \\
            \emph{pa rum pum pum pum},\\
            I am a poor boy, too,\\
            \emph{pa rum pum pum pum},\\
            I have no gift to bring,\\
            \emph{pa rum pum pum pum},\\
            that's fit to give a King,\\
            \emph{pa rum pum pum pum},\\
            \emph{rum pum pum pum,\\ rum pum pum pum}

            Shall I play for you,\\
            \emph{pa rum pum pum pum},\\
            on my drum? 

    \end{multicols}
    \begin{flushright}
      Ordinary flushright text.
    \end{flushright}
    \begin{flushright}%
      \setlength{\rightskip}{3em}%
            3. Mary nodded, \emph{pa rum pum pum pum},\\
            the ox and lamb kept time, \emph{pa rum pum pum pum},\\
            I played my drum for Him, \emph{pa rum pum pum pum},\\
            I played my best for Him, \emph{pa rum pum pum pum},\\
            rum pum pum pum, rum pum pum pum.

            Then He smiled at me, \emph{pa rum pum pum pum},\\
            me and my drum.

    \end{flushright}
\end{document}

答案2

以下是两个不需要指定明确长度的示例:

\documentclass[fontsize=12pt,paper=A5,DIV=20,headinclude=true,footinclude=true,headings=small,pagesize,parskip=half]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,naustrian]{babel}
\usepackage[babel=true,protrusion=true,factor=900,draft=false]{microtype}

\usepackage{multicol, sectsty}

\usepackage{varwidth}

\raggedbottom
\addtolength{\topmargin}{-1cm}
\addtolength{\textheight}{2.5cm}
\allsectionsfont{\large\centering}

\begin{document}
    \section{The Little Drummer Boy}
        \begin{multicols}{2}

            1. Come, they told me,\\ 
            \emph{pa rum pum pum pum},\\
            our new born King to see, \\
            \emph{pa rum pum pum pum},\\
            our finest gifts we'll bring, \\
            \emph{pa rum pum pum pum},\\
            to lay before the King, \\
            \emph{pa rum pum pum pum},\\
            \emph{rum pum pum pum,\\ rum pum pum pum.}

            So to honor Him,\\ 
            \emph{pa rum pum pum pum},\\
            when we come.

        \columnbreak

            2. Little Baby, \\
            \emph{pa rum pum pum pum},\\
            I am a poor boy, too,\\
            \emph{pa rum pum pum pum},\\
            I have no gift to bring,\\
            \emph{pa rum pum pum pum},\\
            that's fit to give a King,\\
            \emph{pa rum pum pum pum},\\
            \emph{rum pum pum pum,\\ rum pum pum pum}

            Shall I play for you,\\
            \emph{pa rum pum pum pum},\\
            on my drum? 

    \end{multicols}

    \noindent
    \rule{\textwidth}{1pt}

    \begin{center}
      \begin{varwidth}{\linewidth}
        \begin{flushright}
          3. Mary nodded, \emph{pa rum pum pum pum},\\
          the ox and lamb kept time, \emph{pa rum pum pum pum},\\
          I played my drum for Him, \emph{pa rum pum pum pum},\\
          I played my best for Him, \emph{pa rum pum pum pum},\\
          rum pum pum pum, rum pum pum pum.

          Then He smiled at me, \emph{pa rum pum pum pum},\\
          me and my drum.
        \end{flushright}
      \end{varwidth}
    \end{center}

    \begin{center}
      \begin{tabular}{@{}r@{}}
        3. Mary nodded, \emph{pa rum pum pum pum},\\
        the ox and lamb kept time, \emph{pa rum pum pum pum},\\
        I played my drum for Him, \emph{pa rum pum pum pum},\\
        I played my best for Him, \emph{pa rum pum pum pum},\\
        rum pum pum pum, rum pum pum pum.\\
        Then He smiled at me, \emph{pa rum pum pum pum},\\
        me and my drum.
      \end{tabular}
    \end{center}
  \end{document}

在此处输入图片描述

答案3

以下是使用该changepage包的另一个建议:

我们利用adjustwidth控制相关文本左边距和右边距的环境:

\begin{adjustwidth}{0in}{1in} % Here 1in defines the extra tabbing you need. 
    \begin{flushright}
    3. Mary nodded, \emph{pa rum pum pum pum},\\
    the ox and lamb kept time, \emph{pa rum pum pum pum},\\
    I played my drum for Him, \emph{pa rum pum pum pum},\\
    I played my best for Him, \emph{pa rum pum pum pum},\\
    rum pum pum pum, rum pum pum pum.

    Then He smiled at me, \emph{pa rum pum pum pum},\\
    me and my drum.
   \end{flushright}
\end{adjustwidth}

在此处输入图片描述

对于 MWE,请参见下文:

\documentclass[fontsize=12pt,paper=A5,DIV=14,headinclude=true,footinclude=true,headings=small,pagesize,parskip=half]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,naustrian]{babel}
\usepackage[babel=true,protrusion=true,factor=900,draft=false]{microtype}
%\usepackage{MinionPro}
\usepackage[oldstyle,semibold]{sourcesanspro}

\usepackage{multicol, sectsty}
\usepackage{changepage}

\raggedbottom
\addtolength{\topmargin}{-1cm}
\addtolength{\textheight}{2.5cm}
\allsectionsfont{\large\centering}

\begin{document}
    \section{The Little Drummer Boy}
        \begin{multicols}{2}

            1. Come, they told me,\\ 
            \emph{pa rum pum pum pum},\\
            our new born King to see, \\
            \emph{pa rum pum pum pum},\\
            our finest gifts we'll bring, \\
            \emph{pa rum pum pum pum},\\
            to lay before the King, \\
            \emph{pa rum pum pum pum},\\
            \emph{rum pum pum pum,\\ rum pum pum pum.}

            So to honor Him,\\ 
            \emph{pa rum pum pum pum},\\
            when we come.

        \columnbreak

            2. Little Baby, \\
            \emph{pa rum pum pum pum},\\
            I am a poor boy, too,\\
            \emph{pa rum pum pum pum},\\
            I have no gift to bring,\\
            \emph{pa rum pum pum pum},\\
            that's fit to give a King,\\
            \emph{pa rum pum pum pum},\\
            \emph{rum pum pum pum,\\ rum pum pum pum}

            Shall I play for you,\\
            \emph{pa rum pum pum pum},\\
            on my drum? 

    \end{multicols}
        \begin{adjustwidth}{0in}{1in} % Here 1in defines the extra tabbing you need. 
    \begin{flushright}
            3. Mary nodded, \emph{pa rum pum pum pum},\\
            the ox and lamb kept time, \emph{pa rum pum pum pum},\\
            I played my drum for Him, \emph{pa rum pum pum pum},\\
            I played my best for Him, \emph{pa rum pum pum pum},\\
            rum pum pum pum, rum pum pum pum.

            Then He smiled at me, \emph{pa rum pum pum pum},\\
            me and my drum.
    \end{flushright}
    \end{adjustwidth}
\end{document}

\hfill您还可以使用和环境的组合minipage。如下所示:

\null\hfill
\begin{minipage}{0.8\textwidth}
 \begin{flushright}
    3. Mary nodded, \emph{pa rum pum pum pum},\\
    the ox and lamb kept time, \emph{pa rum pum pum pum},\\
    I played my drum for Him, \emph{pa rum pum pum pum},\\
    I played my best for Him, \emph{pa rum pum pum pum},\\
    rum pum pum pum, rum pum pum pum.

    Then He smiled at me, \emph{pa rum pum pum pum},\\
    me and my drum.
\end{flushright}
\end{minipage}
\hfill\null

\begin{addmargin}[0in]{1in}...由于使用了 KOMA 类,@cgnieder 建议使用类似的环境来实现所需的结果。

\begin{addmargin}[0in]{1in}
\begin{flushright}
   3. Mary nodded, \emph{pa rum pum pum pum},\\
      the ox and lamb kept time, \emph{pa rum pum pum pum},\\
      I played my drum for Him, \emph{pa rum pum pum pum},\\
      I played my best for Him, \emph{pa rum pum pum pum},\\
      rum pum pum pum, rum pum pum pum.

      Then He smiled at me, \emph{pa rum pum pum pum},\\
      me and my drum.
\end{flushright}
\end{addmargin}

相关内容