3

I want to use an ornament from the pgfornaments package as the headsepline in a KOMA-Script scrbook. A minimal working example of my document would be something like:

\documentclass[a4paper,ngerman,headsepline, BCOR=5mm, numbers=noenddot, sort&compress]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}

\setkomafont{sectioning}{\bfseries} % Serifen und Überschriften
\setkomafont{descriptionlabel}{\bfseries}

\begin{document}
some lorem here
\end{document}

So is there a way to "replace" or renew the headsepline option to draw an ornament (like ornament #88 from pgfornaments) to use as header?

I searched for ornament options here, but I didn't find any with specific mentioning of using it as a header separator line and the documentation of pgfornaments also didn't really help me either. There is a mention of designing own heads in KOMA Script here: How to change \headsepline color in KOMA-Scriptclasses , but to be honest, I am not experienced enough in LaTeX to have an idea on hjow to start.

To clarify as to what I want to achieve (that doesn't look horribly uggly): I have three options in mind to try out whether they work (although only one option per document. SO I won't interchange them inside a single document)

  1. Have the horizontal header separator line be interrupted in the center with an ornament like pgfornament #12 pgfornament 12 as center ornament and therefore make the header separator line just a tiny bit more fancy

  2. Maybe have both outer end of the header separator line be "finished" with eg ornament #21 pfgornament 21 as left line end as the left end and ornament #23 pgfornament 23 as right line end as the right end of the line.

  3. Or approach it per left/right page and have the outer end of the line (on a right page, the right side and on the left page the left side) and only on the outer sides end the line with ornaments like in the second option of this list

Edit: My current code thatnks to Keks Dose is the following (although it doesn't account for the space introduced by headsepline usually) and probably ugly:

\documentclass[a4paper,ngerman]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{scrlayer-scrpage}
\usepackage{pgfornament, blindtext}
\usepackage{showframe}

\setkomafont{sectioning}{\bfseries} % Serifen und Überschriften
\setkomafont{descriptionlabel}{\bfseries}

\chead{%
\raisebox{-3mm}{
\rule{0.4\linewidth}{0.2mm}%
\pgfornament[width=2mm]{13}
\rule{0.4\linewidth}{0.2mm}}
}

\automark[chapter]{chapter}

\automark*[section]{}

\pagestyle{scrheadings}

\begin{document}
\blinddocument
\chapter{more blindtext with a very very very long name}
\blindtext[12]


\end{document}

My code also doesn't yet rotate the ornament by 90 ° and also doesn't correctly set the width of the rules, but I'm working on it.

Current status: current working status

  • I think this could work with the new package scrlayer-scrpage. – Johannes_B Sep 1 '14 at 13:16
  • ok, but how would I approach this? The linked response from cgnieder mentiones scrlayer-scrpage, but how to implement? I am sadly not that tex-savvy, do you have a code snippet maybe? – Hug Sep 1 '14 at 13:18
  • 1
    It's a bit more complicated here. Just wait a bit, somebody will find a solution. I am going to take a look myself. – Johannes_B Sep 1 '14 at 13:20
  • didn't mean to be impatient. Thank you very much! – Hug Sep 1 '14 at 13:20
  • @Johannes_B do you think I can add more info or specifics to the question to increase likelyhood of an answer? – Hug Sep 4 '14 at 16:33
5

Maybe my solution is pretty simple, but I'd start here:

\documentclass[a4paper,ngerman, headheight=3ex]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{scrlayer-scrpage}
\usepackage{pgfornament, blindtext}

\setkomafont{sectioning}{\bfseries} % Serifen und Überschriften
\setkomafont{descriptionlabel}{\bfseries}

\chead{\headmark\\%
\pgfornament[width=\textwidth]{88}}
\automark[chapter]{chapter}
\ohead{}

\begin{document}
\blinddocument

\end{document}
  • +1 from my side, this is the simplest solution. But i wanted to learn something about the internals. Very interesting package ;-) – Johannes_B Sep 5 '14 at 16:07
  • 1
    @Johannes_B The package author will give a speech on September 20th in Karlsruhe at the semiannual Dante meeting, about scrlayer. See here: dante.de/events/Herbst2014/Programm.html Please register and come! – Keks Dose Sep 5 '14 at 20:02
  • I'd like to meet him in person, but i cannot make it to the meeting this year. Maybe next year and we have a drink with Elke. ;-) – Johannes_B Sep 5 '14 at 20:06
  • @KeksDose So I am trying to understand both answers at the moment, but I'll try to understand this one first as it seems easier. ;-) Where can I find the documentation for commands like "\automark" and "\headmark"? Your solution also seems to dismiss the previous formatting of header being dependent on which side of the document it is and left/right orientation. – Hug Sep 6 '14 at 13:01
  • 1
    Things like \headmark and \automark are described in every LaTeX introduction. The solution above uses them as well, as they are the standards, and don't get touched. You should also have a look at the KOMA-script documentation. Don't be scared, it is a whole lot of information. – Johannes_B Sep 6 '14 at 13:28
4

I never used the internals of package scrlayer and i am pretty sure there is a much better way. For example using the higher level interface of package scrlayer-scrpage.

Here is a first draft and i looks pretty ugly:

enter image description here

%\RequirePackage{filecontents}
\begin{filecontents}{\jobname.sty}
\ProvidesPackage{\jobname}[2014/09/05 v 0.1  pgfornaments
and scrlayer-scrpage]
\RequirePackage{pgfornament}
\RequirePackage{scrlayer-scrpage}
\RequirePackage{adjustbox}
\RequirePackage{etoolbox}
\AtEndPreamble{\KOMAoptions{headsepline=false,headinclude=true}\recalctypearea}
\newcommand{\JB@ornament}{%
    \begin{adjustbox}{max width=\textwidth}%
        \pgfornament{88}%
\end{adjustbox}%
}
    \DeclareLayer[%
      background,%
      hoffset=\sls@leftmargin{head},%
      voffset=\sls@topmargin+\headheight,%
      width=\sls@headwidth,%
      height=0pt,%
      align=tl,%
      contents={%
        {\normalfont\usekomafont{pageheadfoot}{\usekomafont{pagehead}{%
      \JB@ornament
}}}
      }%
    ]{scrheadings.head.below.line}%
\AddLayersAtBeginOfPageStyle{scrheadings}{%
scrheadings.head.below.line
}
\pagestyle{scrheadings}
\endinput
\end{filecontents}



\documentclass{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{showframe}
\usepackage{\jobname}

\setkomafont{sectioning}{\bfseries}
\setkomafont{descriptionlabel}{\bfseries}
\KOMAoptions{headinclude=false}
\begin{document}
\Blinddocument lorem here
\chapter{more blindtext}
\blindtext[12]
\end{document}
  • I will take a look after lunch. I think a combination of left and right little ornaments with a HRule makes more sense ;-) – Hug Sep 5 '14 at 9:50
  • Thank you for the answer. I didn't manage to test it out yesterday. In trying to understand what is being done here: Are you actually producing a package one calls in the preamble? Also, I updated the question to clarifiy how I imagine ornaments being not as ugly ;-) If I have code working for line-ornament-line, could I just replace the "\pgfornament{88}%" line with this? – Hug Sep 6 '14 at 13:19
  • Yes, a package is created just because @ signs are treated as letters there. If you want to go with that solution, you might need to add stuff and using a package, the preamble does not get littered. I wanted to implement options at the beginning, to keep the package as flexible as possible, but i think there really is no need for it as including an ornament can be very easily done using @Keks approach. If you want to change the ornament, change the definition of \JB@ornament. – Johannes_B Sep 6 '14 at 13:24
  • >> Just looked to your additions. If you want to be able to change the look by having separate things to choose from, definitely use the package approach with different options. – Johannes_B Sep 6 '14 at 13:26
  • @Hug I don't know if you are pinged automatically, so please check out my comments to both answers. – Johannes_B Sep 6 '14 at 14:48

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.