1

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[
%      head,
%      height=0pt,
%      foreground,
%      contents=\textcolor{gray!70}{\layercontentsmeasure}
%    ]{head.ruler}
    \DeclareNewLayer[
      foot,
      height=\textheight+0.1cm,
      addvoffset=-\textheight-1.2cm,
      background,
      contents=\textcolor{lightgray}{\layercontentsmeasure}
    ]{foot.ruler}
    \AddLayersAtBeginOfPageStyle{scrheadings}{foot.ruler}
    \AddLayersAtBeginOfPageStyle{plain.scrheadings}{foot.ruler}
    \AtBeginDocument{\chead*{DRAFT}\cfoot*{DRAFT}}
  }
\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);
  3. add the word DRAFT also to the chapter (table of contents etc.) pages (SOLVED);
  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,
        addvoffset=\myrcoeff\dimexpr-\headsep\relax,
        height=\textheight+\myrcoeff\dimexpr\headsep+\footskip-\footheight\relax,
        addhoffset=\myrcoeff\dimexpr-\headsep-.5\footskip+.5\footheight\relax,
        width=\textwidth+\myrcoeff\dimexpr+2\headsep+\footskip-\footheight\relax,
        background,
        contents=\textcolor{lightgray}{\layercontentsmeasure}
        ]{textarea.ruler}
        \AddLayersAtBeginOfPageStyle{scrheadings}{textarea.ruler}
        \AddLayersAtBeginOfPageStyle{plain.scrheadings}{textarea.ruler}
        \newcommand{\myhfc}{\textcolor{gray}{\textls[667]{DRAFT}}}
        \newcommand{\myhfl}{\cleaders\hbox{\,\textcolor{gray}{---}\,}\hfill}
        \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{%
            \chead*{\myhf}
            \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}

enter image description here

7
  • I guess that something gets confused by using geometry whereas classicthesis expects typearea.
    – egreg
    Feb 25 '18 at 18:04
  • When geometry line is commented out, the problem persists - I just added it to show bigger rulers.
    – Peter
    Feb 25 '18 at 18:06
  • 1
    The bug is in scrlayer-scrpage (or, better, in scrlayer).
    – egreg
    Feb 25 '18 at 18:22
  • 1
    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.
    – egreg
    Feb 25 '18 at 18:35
  • 1
    See tex.stackexchange.com/a/328532/43317
    – esdd
    Feb 25 '18 at 18:44
3

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}

enter image description here


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[
      head,
      height=0pt,
      foreground,
      contents=\textcolor{gray!70}{\layercontentsmeasure}
    ]{head.ruler}
    \DeclareNewLayer[
      foot,
      height=0pt,
      addvoffset=\footheight-\dp\strutbox,
      background,
      contents=\textcolor{lightgray}{\layercontentsmeasure}
    ]{foot.ruler}
    \AddLayersAtBeginOfPageStyle{scrheadings}{head.ruler,foot.ruler}
    \AddLayersAtBeginOfPageStyle{plain.scrheadings}{head.ruler,foot.ruler}
    \AtBeginDocument{\chead*{DRAFT}\cfoot*{DRAFT}}
  }
\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}

enter image description here

2
  • 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.
    – Peter
    Feb 25 '18 at 21:16
  • 1
    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
1

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]{%
        \IfLayerAtPageStyle{scrheadings}{#2}{%
            \DeclareNewLayer[clone=#2,contents=\textcolor{#1}{\layercontentsmeasure}]{#2.size}%
            \AddLayersToPageStyleAfterLayer{scrheadings}{#2.size}{#2}%
        }{}%
    }
    %\showlayer[lightgray]{scrheadings.head.oneside}
    \showlayer[red!30]{scrheadings.head.below.line}
    %\showlayer[green!30]{scrheadings.head.above.line}
    %\showlayer[lightgray]{scrheadings.foot.oneside}
    \showlayer[red!30]{scrheadings.foot.above.line}%
    %\showlayer[green!30]{scrheadings.foot.below line}%
}{}

\usepackage{classicthesis}
\usepackage{arsclassica}

\ifoptiondraft{%
    \chead{DRAFT}
    \cfoot{DRAFT}%
}{}

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

\begin{document}
    Text.
\end{document}

Resulting image.

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.