9

So I am typesetting a little songbook for our Christmas get-together. To make better use of the limited space, I am using the multicol package; no issues there.

What I'd like to do is move a whole paragraph horizontally an arbitrary amount of space. In the following MWE take a look at stanza #3. It uses a \begin{flushright} environment, but I'd still like to move it a bit more to the center, keeping the right edge neatly aligned.

\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}

enter image description here

8

You can simply specify a different \rightskip inside the flushright. flushright works by putting \rightskip to 0pt and \leftskip to exandable glue. Replace the \rightskip value by some positive length, e.g. by

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

Sample output

\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}
  • 4
    for a verse this is probably OK but it's worth noting that changing \rightskip directly is not generally safe in latex and will break any nested display structures as they will not know the effective line width. making a simple list environment (like flushleft or quote but modifying the setting of \rightmargin rather than \rightskip would ensure that \@totalleftmargin and \linewidth got updated as the margin changed. – David Carlisle Dec 3 '13 at 15:41
  • Thank you, it's working beautifully. @David: Duly noted, but luckily that's not an issue in my little example. – Ingmar Dec 3 '13 at 16:21
  • 3
    @Ingmar I guessed not, but code on the forum lasts forever and gets copied who knows where:-) – David Carlisle Dec 3 '13 at 16:23
  • @DavidCarlisle What do you use to compile this document. I dont seem to have the MinionPro.sty – azetina Dec 3 '13 at 19:12
  • @azetina I didn't:-) but the main point of the question doesn't need the font packages, it would apply to cm just as much. – David Carlisle Dec 3 '13 at 19:16
4

Here are two examples where you don't need to specify an explicit length:

\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}

enter image description here

1

Here is another suggestion using the changepage package:

We make use of the adjustwidth environment that controls the left and right margin of the text in question:

\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}

enter image description here

For a MWE, see below:

\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}

You can also use a combination of \hfill and the minipage environment. See below:

\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

@cgnieder suggests using the \begin{addmargin}[0in]{1in}... like environment to achieve the desired result since a KOMA class is being used.

\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}
  • 1
    Since a KOMA class is used I'd rather use KOMA-Script's \begin{addmargin}[0in]{1in} ... which should do the same – clemens Dec 3 '13 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.