0

I'm having trouble to get the vertical line in the footer shorter. I don't want the line to be pulled through to the bottom of the page. Instead I want it either only the height of the page number or a bit longer like double, the line going also down not up. So either I can define the length or smash, idk please help.

With the geometry package I can get the page number down, but that's not what I want.

\documentclass[12pt, a4paper]{scrreprt}
\usepackage{xcolor}
\usepackage{fancyhdr}
\usepackage{lipsum}
%\usepackage[margin=1in]{geometry}

\fancyhf{}
\fancyfoot[R]{\vfootline\hskip\linepagesep\thepage}
\renewcommand\headrulewidth{0pt}
\newskip\linepagesep \linepagesep 5pt\relax
\def\vfootline{%
   \begingroup\color{blue}\rule[-990pt]{1pt}{1000pt}\endgroup}

\pagestyle{fancy}

\begin{document}
   \lipsum
   \lipsum
   \lipsum
\end{document}

2 Answers 2

0

You have to change the options for \rule:

\documentclass[12pt, a4paper]{scrreprt}
\usepackage{lipsum}% only for dummy text
\usepackage{xcolor}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand\headrulewidth{0pt}
\fancyhf{}
\fancyfoot[R]{\vfootline\hspace{\linepagesep}\thepage}

\newlength\linepagesep
\setlength{\linepagesep}{5pt}
\newcommand*\vfootline{\textcolor{blue}{\rule[-2pt]{1pt}{2\ht\strutbox}}}

\begin{document}
   \lipsum
   \lipsum
   \lipsum
\end{document}

enter image description here

The syntax of \rule is

\rule[<vertical shift>]{<width of the rule>}{<height of the rule>}

If the rule should go down you could use eg.

\rule[-\ht\strutbox]{1pt}{2\ht\strutbox}

enter image description here


Remark: You are using a KOMA-Script class. So it is recommended to use package scrlayer-scrpage instead fancyhdr:

\documentclass[12pt, a4paper,twoside,footheight=23pt]{scrreprt}
\usepackage{blindtext}% only for dummy text
\usepackage{xcolor}
\usepackage{scrlayer-scrpage}% sets pagestyle scrheadings automatically
\clearpairofpagestyles
\rofoot*{\vfootline\hspace{\linepagesep}\pagemark}
\lefoot*{\pagemark\hspace{5pt}\vfootline}% for twosided document

\newlength\linepagesep
\setlength{\linepagesep}{5pt}
\newcommand*\vfootline{\textcolor{blue}{\rule[-2pt]{1pt}{2\ht\strutbox}}}

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

Other example:

\documentclass[12pt, a4paper,footlines=2]{scrreprt}
\usepackage{lipsum}% only for dummy text
\usepackage{xcolor}
\definecolor{ultramarineblue}{rgb}{0.25, 0.4, 0.96}

\renewcommand\chaptermarkformat{\chaptername\ \thechapter\autodot\ \ }

\usepackage[automark,headsepline,markcase=upper]{scrlayer-scrpage}
\clearpairofpagestyles
\ohead{\leftmark}
\rofoot*{\vfootline\hspace{\linepagesep}\pagemark}
\lefoot*{\pagemark\hspace{5pt}\vfootline}% for twosided document

\addtokomafont{headsepline}{\color{ultramarineblue}}

\newlength\linepagesep
\setlength{\linepagesep}{5pt}
\newcommand*\vfootline{{\usekomafont{headsepline}\rule[-2pt]{1pt}{2\ht\strutbox}}}

\begin{document}
    \chapter{CTitle}
   \lipsum
    \section{STitle}
   \lipsum
\end{document}

enter image description here

Note that the star in \rofoot* and \lefoot* ensures that page style plain will use the same contents as page style scrheadings. By default chapter pages get page style plain.

0
0

Why is it so bad to use fancyhdr? I have some other things I use that I need fancyhdr for. And it works fine. Btw I'm a newbie to Latex.

\documentclass[12pt, a4paper]{scrreprt}
\usepackage{lipsum}% only for dummy text
\usepackage{xcolor}
\usepackage{fancyhdr}
\definecolor{ultramarineblue}{rgb}{0.25, 0.4, 0.96}

\pagestyle{fancy} % Turn on the style
\fancyhf{}
\renewcommand{\headrule}{{\color{ultramarineblue}%
    \hrule width\headwidth height\headrulewidth \vskip-\headrulewidth}}
\renewcommand{\headrulewidth}{0.4pt} 
\fancyhead[R]{\textsl{\leftmark}}
\fancyfoot[R]{\vfootline\hspace{\linepagesep}\thepage}

\fancypagestyle{plain}{%
    \fancyhf{} % clear all header and footer fields
    \fancyfoot[R]{\vfootline\hspace{\linepagesep}\thepage}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}}

\newlength\linepagesep
\setlength{\linepagesep}{5pt}
\newcommand*\vfootline{\textcolor{blue}{\rule[-2pt]{1pt}{2\ht\strutbox}}}

\begin{document}
    \chapter{CTitle}
   \lipsum
    \section{STitle}
   \lipsum
\end{document}
1
  • This is not a new answer to your question but a comment to my answer. It it would be really, really bad to use fancyhdr my first suggestion would not use this package. But fancyhdr breaks some KOMA-Script features. Eg. options headsepline, footsepline etc. does not have an affect and you can not use \addtokomafont or \setkomafont to change the font of page header and footer etc. So it is recommended to use the KOMA-Script package scrlayer-scrpage while it is still possible to use fancyhdr.
    – esdd
    Feb 5, 2018 at 12:53

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.