0

When I use the command to have a short footer at the bottom of the pages, the short footer line always appears at the left of the footer. How can I change the position of the short footer for the odd pages to be on the right and for the even pages on the left?

the command :

\renewcommand\footrule{\hrule width0.2\textwidth}

the footer needs to be on the right side here

enter image description here

1
  • Welcome to TeX.SE!
    – Zarko
    Dec 19, 2022 at 13:44

2 Answers 2

2

It might be easier to use \rule, because \hrule is a TeX primitive and therefore a bit tricky to handle. With \rule, you can do:

\documentclass{article}
\usepackage{fancyhdr}

\pagestyle{fancy}
\renewcommand{\footrulewidth}{0.4pt}
\renewcommand\footrule{\hfill\rule{0.2\textwidth}{\footrulewidth}\hfill\null}

\begin{document}

Foo

\end{document}

enter image description here


For different adjustment depending on whether the page number is even or odd you can do something like this:

\documentclass[twoside]{article}
\usepackage{fancyhdr}

\pagestyle{fancy}

\fancyfoot{}
\fancyfoot[LE,RO]{\thepage}

\renewcommand{\footrulewidth}{0.4pt}
\renewcommand\footrule{%
    \ifodd\value{page}%
        \hfill\rule{0.2\textwidth}{\footrulewidth}%
    \else%
        \rule{0.2\textwidth}{\footrulewidth}\hfill%
    \fi%
}

\begin{document}

Foo

\newpage

Bar

\end{document}

enter image description here

enter image description here


If you still want to stick to \hrule, you can do:

\documentclass[twoside]{article}
\usepackage{fancyhdr}

\pagestyle{fancy}

\fancyfoot{}
\fancyfoot[LE,RO]{\thepage}

\renewcommand{\footrulewidth}{0.4pt}
\renewcommand\footrule{%
    \ifodd\value{page}%
        \moveright0.8\textwidth\vbox{\hrule width0.2\textwidth}%
    \else%
        \hrule width0.2\textwidth%
    \fi%
}

\begin{document}

Foo

\newpage

Bar

\end{document}

(The output is the same as above.)

0
2
\renewcommand{\footrulewidth}{\headrulewidth}
\renewcommand\footrule{\makebox[\textwidth]{\ifodd\value{page}\hfill\fi\rule{0.2\textwidth}{\footrulewidth}\ifodd\value{page}\else\hfill\fi}}

You must log in to answer this question.

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