0

I am working on a twosided article layout where the footnotes are enclosed by two \textwidth lines above and below and on pages without a footnote a single h-line is spanning across \textwidth at the bottom of the text-body. But the footer itself should span across \textwidth plus \marginparwidth

I tried the fancyhdr to create a line at the border between footer and text-body, but on even pages the footrule hangs on the wrong side:

footrule hanging on wrong side on even pages

It should look like on odd pages:

enter image description here

Here is a MWE:

\documentclass[a4paper,12pt,
twoside,%
]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{geometry}
\geometry{%
    inner=2cm,
    outer=4cm,
    top=2.5cm,
    bottom=2.5cm,
    marginparwidth=3cm,
}
\setlength\parindent{0pt}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\fancyfoot[EL,OR]{\textbf{\thepage}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.5pt}
\addtolength{\headwidth}{\marginparwidth}
\renewcommand\footrule{\hrule width\textwidth}
\fancypagestyle{plain}{}

\usepackage[%
hang,%
%marginal,%
bottom%
]{footmisc}
\setlength{\footnotemargin}{0.5cm} %Abstand zwischen textkörper und FN bei hang-option
%\setlength{\footnotesep}{0.35cm} %Abstand zwischen FN
\setlength{\skip\footins}{0,5cm} %Abstand zwischen FN-Nummer und FN-Text
\renewcommand{\footnoterule}{\rule{\textwidth}{0.5pt}{\vspace*{2mm}}}

\usepackage{blindtext}

\begin{document}
    \blindtext[3]\footnote{text}
    \blindtext[3]\footnote{text}
    \blindtext[4]
\end{document}

The important part oft the layout is the horizontal rule at the bottom of the text-body, on pages with and without footnotes.

I guess some more professional TeX-users can offer a solution.

Edit:

If someone has another solution without fancyhdr, I'm also happy. As long as it looks like the second picture and offers a footer spanning through textwidth and marginparwidth (where the pagenumber is displayed).

2. Edit:

Unfortunatley, the test pages which i got to style the Latex layout had footnotes on every page. But the layout expects a single hrule at the bottom of the text-body also on pages without a footnote. Therefore, @cabohah's great solution doesn't fit my needs, because the lower rule only appears if a footnote-command is called. Sorry for the confusion. Is there a possibility to place a hrule on the bottom of the text-body of every page, notwithstanding if there is a footnote or not? Also updated the initial question above with this requirement.

Thanks and best!

5
  • 1
    Just a note: footnotes are part of the text area not of the page footer, so they are independent of the page styles defined by fancyhdr.
    – cabohah
    Commented May 23, 2023 at 9:06
  • Another note: If you don't like paragraph indent, you should not only switch this of, but use another paragraph markup like paragraph skip, e.g., using package parskip. Otherwise it could happen, that (some) paragraphs become unrecognizable. See for example: How to correctly prevent paragraph indentation.
    – cabohah
    Commented May 23, 2023 at 9:08
  • @caboha, thanks for your comment. I know footnotes and footer are not the same. But Due to the journal layout i need a rule above and below the footnote. Using fancyhdr is a workaround, other solutions are welcome if they provide the needed result. In the full document the paragraph has some additional options which are not needed for the MWE and are fully recognizable
    – lukeflo
    Commented May 23, 2023 at 9:54
  • But if the footnotes are not part of the page footer, it makes no sense to move them according. So the question would just be, how to add a horizontal line not only above the footnotes but also below. This would be a completely different question. (And IMHO the answer would be to patch \@makecol.)
    – cabohah
    Commented May 23, 2023 at 9:58
  • That sounds very interesting. Maybe my initial topic was a little confusing. If it solves the Problem and results in image 2 without touching the footer, its even better. Could you provide an example, how to make it work? I've little experience in patching those commands.
    – lukeflo
    Commented May 23, 2023 at 10:39

1 Answer 1

1

Instead of trying to add the rule below the footnotes to the page footer, you could patch the output of the footnotes:

\documentclass[a4paper,12pt,twoside,]{article}
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}% not needed with LaTeX 2018/04/01 or newer

\usepackage{geometry}
\geometry{%
    inner=2cm,
    outer=4cm,
    top=2.5cm,
    bottom=2.5cm,
    marginparwidth=3cm,
}
\usepackage{parskip}

\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\fancyfoot[EL,OR]{\textbf{\thepage}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headwidth}{\marginparwidth}
\fancypagestyle{plain}{}

\usepackage[hang,bottom]{footmisc}
\setlength{\footnotemargin}{0.5cm} %Abstand zwischen textkörper und FN bei hang-option
%\setlength{\footnotesep}{0.35cm} %Abstand zwischen FN
\setlength{\skip\footins}{0,5cm} %Abstand zwischen FN-Nummer und FN-Text

\makeatletter
\renewcommand\footnoterule{\kern-3\p@
  \hrule \@width \textwidth \kern 2.6\p@} % the \hrule is .4pt high and now it has the width of the text area
\makeatother

\usepackage{xpatch}
% NOTE: The following code depends on usage of package footmisc!
\makeatletter
\xpatchcmd{\@outputbox@appendfootnotes}{%
  \unvbox \footins
}{%
  \unvbox \footins
  \secondfootnoterule
}{}{\PAtchFailure}
\newcommand*{\secondfootnoterule}{\hrule \@width \textwidth \kern -0.4\p@}
\makeatother

\usepackage{blindtext}

\begin{document}
    \blindtext[3]\footnote{text}
    \blindtext[3]\footnote{text}
    \blindtext[4]
\end{document}

enter image description here

Here a similar solution, for those who do not use footmisc:

\documentclass[a4paper,12pt,twoside,]{article}
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}% not needed with LaTeX 2018/04/01 or newer

\usepackage{geometry}
\geometry{%
    inner=2cm,
    outer=4cm,
    top=2.5cm,
    bottom=2.5cm,
    marginparwidth=3cm,
}
\usepackage{parskip}

\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\fancyfoot[EL,OR]{\textbf{\thepage}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headwidth}{\marginparwidth}
\fancypagestyle{plain}{}

\usepackage{xpatch}
% NOTE: The following code depends on NOT using package footmisc!
\makeatletter
\xpatchcmd{\@makecol}{%
  \unvbox \footins
}{%
  \unvbox \footins
  \secondfootnoterule
}{}{\PAtchFailure}
\renewcommand\footnoterule{\kern-3\p@\hrule \@width \textwidth \kern 2.6\p@} % the \hrule is .4pt high and has the width of the text area
\newcommand*{\secondfootnoterule}{\hrule \@width \textwidth \kern -0.4\p@}
\makeatother

\usepackage{blindtext}

\begin{document}
    \blindtext[3]\footnote{text}
    \blindtext[3]\footnote{text}
    \blindtext[4]
\end{document}

enter image description here


EDIT because of change of question to a completely different one

If you are just asking for a separation line above the page footer, that should only span the width of the text area, despite the page number should be aligned at the outer edge of the \marginpar column, the simplest solution would be to use package scrlayer-scrpage. It provides not only to set the line length independent from the footer width, but also to align all separation lines either centered, inner aligned or outer aligned. So

\documentclass[a4paper,12pt,twoside]{article}
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}% not needed with LaTeX 2018/04/01 or newer

\usepackage{geometry}
\geometry{%
    inner=2cm,
    outer=4cm,
    top=2.5cm,
    bottom=2.5cm,
    marginparwidth=3cm,
}
\usepackage{parskip}

\usepackage[footwidth=textwithmarginpar,footsepline=0.4pt:text,ilines]{scrlayer-scrpage}
\clearpairofpagestyles
\ofoot*{\pagemark}

\usepackage{blindtext}

\begin{document}
\blinddocument
\end{document}

Is enough to get:

using scrlayer-scrpage

If you want a bold page number, you can use \addtokomafont{pagefoot}{\bfseries}.

If you cannot use scrlayer-scrpage for some reason, not expanding the \headwidth but move the pagination into the outer margin would be a suggestion without redefining \footrule:

\documentclass[a4paper,12pt,twoside,]{article}
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}% not needed with LaTeX 2018/04/01 or newer

\usepackage{geometry}
\geometry{%
    inner=2cm,
    outer=4cm,
    top=2.5cm,
    bottom=2.5cm,
    marginparwidth=3cm,
}
\usepackage{parskip}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[EL]{\makebox[0pt][r]{\makebox[\dimexpr\marginparwidth+\marginparsep\relax][l]{\textbf{\thepage}}}}
\fancyfoot[OR]{\makebox[0pt][l]{\makebox[\dimexpr\marginparwidth+\marginparsep\relax][r]{\textbf{\thepage}}}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}
\fancypagestyle{plain}{}

\usepackage{blindtext}

\begin{document}
\Blinddocument
\end{document}

using fancyhdr

6
  • I received new layout informations which unfortunatley need another solution. See my edit above.
    – lukeflo
    Commented May 25, 2023 at 11:12
  • If the rule is a rule above the footer independent from footnotes you should not ask about footnotes but about this rule (without the irrelevant footnote correlation). So it would be a different question than the original one.
    – cabohah
    Commented May 26, 2023 at 6:57
  • Thanks. Yes, of course, you're right. The question changed very much. The problem was that i didn't had all the layout informations at the beginning. At first, it seems that the rule was bound to the footnotes. Sorry for that and thank you again for the solution and your patience.
    – lukeflo
    Commented May 26, 2023 at 8:18
  • 1
    @lukeflo In the future, please don't drastically change an existing question. It would have been better to ask a new question and leave this one as it was. Commented May 26, 2023 at 8:20
  • All right. I thought exact the opposite way: don't ask too much similar questions. Thanks for the clarification, I will bear that in mind for the future.
    – lukeflo
    Commented May 26, 2023 at 8:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .