2

Using scrlayer-scrpage for customizing my footer I have a document which requires a potentially long \ifoot while \ofoot contains only the page number. Unforatunately, the inner footer text is long enough so that it overlaps with the outer footer text. Supposed the text becomes long enough, the line is wrapped automatically, but usually ifoot still overlaps with ofoot. \linebreak[0] has no effect, \linebreak[1] breaks the line every time.

Example:

 \ifoot{Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy 
        eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.}
 \ofoot{\thepage~/~\pageref{LastPage}}

produces

screenshot from given example

I believe I would like to reduce the amount of horizontal space available for ifoot by the horizontal width of ofoot (plus some extra space).

I don't like my current mitigation which includes putting the inner foot into a fixed width minipage. Any suggestions?

2

I can find no option to set the line width in the footer (nor the alignment).

\documentclass[footheight=27.2pt]{scrartcl}
\usepackage{scrlayer-scrpage}
\usepackage{lastpage}

\usepackage{lipsum}

\ifoot{\hsize=350pt
  Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
  sed diam nonumy eirmod tempor invidunt ut labore et dolore
  magna aliquyam erat, sed diam voluptua.}
\ofoot{\thepage~/~\pageref{LastPage}}
\cfoot{}

\begin{document}

\lipsum

\end{document}

enter image description here

Here's how you can set the width just not to cover the page number.

\documentclass[footheight=40.8pt]{scrartcl}
\usepackage{scrlayer-scrpage}
\usepackage{lastpage}

\usepackage{lipsum}

\newlength{\ifootwidth}
\AtBeginDocument{%
  \settowidth{\ifootwidth}{~\pageref{LastPage}~/~\pageref{LastPage}}%
  \setlength{\ifootwidth}{\dimexpr\textwidth-\ifootwidth}%
}

\ifoot{\hsize=\ifootwidth
  Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
  sed diam nonumy eirmod tempor invidunt ut labore et dolore
  magna aliquyam erat, sed diam voluptua.}
\ofoot{\thepage~/~\pageref{LastPage}}
\cfoot{}

\begin{document}
\setcounter{page}{34}

\lipsum

\end{document}

enter image description here

The space reserved is the textwidth minus the width of the page numbers minus a normal space (not really seen in the example because of ragged right setting).

  • This appeared to be almost it. I thought I could just replace the absolute width by width of the line minus \widthof{\pageref{LastPage}~/~\pageref{LastPage}} but failed (the calculation is simply not executed but typeset into the footer). Changing the absolute width to \linewidth is accepted, but if I replace \linewidth by a custom width which was set to the value of \linewidth in advance, the line is wrapped after "invidunt ut" which is far too early (tried that with both TeX dimension and LaTeX length). This confuses me. – Twonky Aug 9 '18 at 7:46
  • @Twonky New version on line – egreg Aug 9 '18 at 18:14
0

You could use \cfoot with a tabularx environment:

\documentclass[footlines=3]{scrartcl}
\usepackage{tabularx}
\usepackage{lastpage}
\usepackage{scrlayer-scrpage}
\clearpairofpagestyles

\cfoot{%
  \begin{tabularx}{\linewidth}{@{}>{\raggedright}X@{\hspace{3em}}r@{}}
    Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy 
    eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
    &
    \thepage~/~\pageref{LastPage}
  \end{tabularx}%
}

\usepackage{lipsum}% only for dummy text
\begin{document}
\lipsum
\end{document}

Result:

enter image description here

Or with a standardclass

\documentclass{article}
\usepackage{tabularx}
\usepackage{lastpage}
\usepackage{scrlayer-scrpage}
\clearpairofpagestyles

\cfoot{%
  \begin{tabularx}{\linewidth}{@{}>{\raggedright}X@{\hspace{3em}}r@{}}
    Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy 
    eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
    &
    \thepage~/~\pageref{LastPage}
  \end{tabularx}%
}
\setlength{\footheight}{36pt}
\setlength\footskip{50pt}

\usepackage{lipsum}% only for dummy text
\begin{document}
\lipsum
\end{document}

Result:

enter image description here

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.