# Duplicated numbers on classicthesis draft rulers

When one uses option draft for classicthesis documents the top and bottom rulers are shown. However, almost in every cas their numbers are duplicated (sometimes that is not the case for first compilation after switching from final to deaft mode). Can this behavior be fixed in some way?

\documentclass[draft]{scrbook}

\usepackage{blindtext}

\ifdim\overfullrule>0pt
\PassOptionsToPackage{draft=false}{scrlayer-scrpage}
\usepackage{xcolor}
\AfterPackage*{scrlayer-scrpage}{%
%    \DeclareNewLayer[
%      height=0pt,
%      foreground,
%      contents=\textcolor{gray!70}{\layercontentsmeasure}
\DeclareNewLayer[
foot,
height=\textheight+0.1cm,
background,
contents=\textcolor{lightgray}{\layercontentsmeasure}
]{foot.ruler}
}
\fi

\usepackage{classicthesis}
\usepackage{arsclassica}
\usepackage[margin=3cm,heightrounded]{geometry} % just to show bigger rulers
\usepackage{lipsum}% only for dummy text

\begin{document}

\chapter{Chapter one}

\blindtext[5]

\end{document}


EDIT #2: The only unsolved of the question below now seems to be putting the numbers and their leading lines outside the bix so it can be shrinked to be of exact size of the textarea.

EDIT: Now I almost managed to get the desired result, but my modification is done in a much unprofessional way. I think the following changes would be made to get the final improvements:

1. display rulers also in vertical direction, roughly main around textblock (something similar to showframe), one side in cm, other in inch (SOLVED);
2. put numbers and their lines on the outside of the rulers rectangle (so they would not interfere with text or head/foot) (UNSOLVED);
4. move the word DRAFT a liter closer vertically to the page borders so that it would not interfere with the document's own head/foot (SOLVED).

Below is the (partial) result I get.

\documentclass[draft]{scrbook}

\usepackage{soulutf8}

\usepackage{ifdraft}

\ifoptiondraft{%
\PassOptionsToPackage{draft=false}{scrlayer-scrpage}
\PassOptionsToPackage{draft=false}{microtype}
\usepackage{xcolor}
\AfterPackage*{scrlayer-scrpage}{%
\def\myrcoeff{1}
\DeclareNewLayer[
textarea,
background,
contents=\textcolor{lightgray}{\layercontentsmeasure}
]{textarea.ruler}
\newcommand{\myhfc}{\textcolor{gray}{\textls[667]{DRAFT}}}
\newcommand{\myhf}[1][1]{\smash{\raisebox{\dimexpr.5\dimexpr#1\headsep+#1\footskip-#1\footheight\relax\relax}{\hbox to \textwidth {\myhfc \myhfl \myhfc \myhfl \myhfc}}}}
\AtBeginDocument{%
\cfoot*{\myhf[-1]}%
}%
}%
}{}

\usepackage{classicthesis}
\usepackage{arsclassica}

\usepackage[onehalfspacing]{setspace}
\raggedbottom

\usepackage[margin=3cm,heightrounded]{geometry} % just to show bigger rulers

\usepackage{blindtext} % only for dummy text

%\usepackage{showframe}

\begin{document}

\chapter{Exemplary chapter title}

\blindtext[5]

\end{document}


• I guess that something gets confused by using geometry whereas classicthesis expects typearea. Feb 25 '18 at 18:04
• When geometry line is commented out, the problem persists - I just added it to show bigger rulers. Feb 25 '18 at 18:06
• The bug is in scrlayer-scrpage (or, better, in scrlayer). Feb 25 '18 at 18:22
• I can reproduce the issue with \documentclass[draft]{article}\usepackage{scrlayer-scrpage}\begin{document}Text.\end{document} The code for the ruler is buggy in scrlayer.sty. Feb 25 '18 at 18:35
• – esdd
Feb 25 '18 at 18:44

Option draft adds a ruler to every layer of a layer page style. A pagestyle defined by scrlayer-scrpage consist of 10 layers and on each page six of them are used: see “draft” class/package option with scrlayer-scrpage.

To avoid the rulers even if class option draft is set, pass draft=false to the package options of scrlayer-scrpage:

\documentclass[draft]{scrbook}
\PassOptionsToPackage{draft=false}{scrlayer-scrpage}
\usepackage{classicthesis}

\usepackage[margin=3cm]{geometry} % just to show bigger rulers
\usepackage{lipsum}% only for dummy text
\begin{document}
\lipsum[1]
\parbox[t]{\textwidth}{\lipsum[2]}% to see the overfullrule if draft is enabled
\end{document}


You could define your own layers with content \layercontentsmeasure. Here is an example that shows the position and lengths of the baseline of header and footer:

\documentclass[draft]{scrbook}
\ifdim\overfullrule>0pt
\PassOptionsToPackage{draft=false}{scrlayer-scrpage}
\usepackage{xcolor}
\AfterPackage*{scrlayer-scrpage}{%
\DeclareNewLayer[
height=0pt,
foreground,
contents=\textcolor{gray!70}{\layercontentsmeasure}
\DeclareNewLayer[
foot,
height=0pt,
background,
contents=\textcolor{lightgray}{\layercontentsmeasure}
]{foot.ruler}
}
\fi
\usepackage{classicthesis}
\usepackage{arsclassica}
\usepackage[margin=3cm]{geometry} % just to show bigger rulers
\usepackage{lipsum}% only for dummy text
\begin{document}
\lipsum[1]
\end{document}


• This is quite useful solution, but the DRAFT word disappears on chapter (or TOC) pages. Also, I think that when the rulers are now much clearer and subtle, they could be also added in vertical direction - I posted my (quite amateur and incomplete) approach to solving this in edited question. Feb 25 '18 at 21:16
• Use the starred versions of \chead and \cfoot to get the word DRAFT on pages with style plain too.
– esdd
Feb 25 '18 at 21:19

Here is what I get in first attempt:

\documentclass[draft]{scrbook}

\usepackage{ifdraft}

\ifoptiondraft{%
\PassOptionsToPackage{draft=false}{scrlayer-scrpage}
\usepackage{scrlayer-scrpage}
\usepackage{xcolor}
\newcommand*\showlayer[2][black]{%
\DeclareNewLayer[clone=#2,contents=\textcolor{#1}{\layercontentsmeasure}]{#2.size}%
}{}%
}
}{}

\usepackage{classicthesis}
\usepackage{arsclassica}

\ifoptiondraft{%