6

I have a book in my possession with page numbers that have graphics surrounding them. I was wondering if there were any way of accomplishing something like this in LaTeX. Here is an example of what I mean:

Example of page number with graphics surrounding it

My document uses the KOMA-script book class.

Thank you ahead of time for any help you can provide.


UPDATE: Using the recommendations by Salim Bou in their answer, this is the specific command that I used to get the effect desired:

\renewcommand{\pagemark}{{\color{gray}\vrule width0.1mm  height1.5ex depth2.5ex \ 
{\color{black}\arabic{page}}\color{gray}\ \vrule  width0.1mm height4ex depth0ex }}

It yields this result:

Preview of result of command shown above

Note: The slight difference between the two lines may be a result of the .pdf viewer I'm using as it's variable from page to page.

1
  • 1
    Renew the pagemark macro to use rules. You can use raisebox to vertically shift the rules. The height of the footer will change, leading to different output.
    – Johannes_B
    Commented Dec 26, 2016 at 7:47

2 Answers 2

3

Here a solution which modify \pagemark command and use \vrule to draw rules beside page number, you can modify thickness of rule by adding width<dim> to vrule like this:

\vrule width1.5pt height1.5ex depth2.5ex 

To change color of rules

{\color{your_color}\vrule width1.5pt height1.5ex depth2.5ex}

In this case you need to add xcolor package


\documentclass{scrbook}
\usepackage{xcolor}
\usepackage{lipsum}
\renewcommand{\pagemark}{{\color{gray}\vrule width1pt  height1.5ex depth2.5ex \ 
{\color{black}\arabic{page}}\ \vrule  width1pt height4ex depth0ex }}
\begin{document}

\lipsum 

\end{document}

enter image description here

3
  • This worked very well when I tried it, thank you. -- Though I will have to change the margins to compensate for the space that the lines took up vertically. The only question I have is this: is it possible to change the color of the lines? In my example picture and in the book I have, they're a lighter gray, so they don't draw so much attention.
    – Aces
    Commented Dec 26, 2016 at 8:13
  • Answer updated.
    – Salim Bou
    Commented Dec 26, 2016 at 8:24
  • The width setting does not change the color, though. Is there a way to change the color, or is there only an option for changing the width? Thank you for the additional information.
    – Aces
    Commented Dec 26, 2016 at 8:34
1

Try using fancyhdr along with TikZ. In the header, put

\usepackage{fancyhdr,tikz}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}

\fancyhead[RO,LE]{
  \begin{tikzpicture}[baseline=20pt]
  \draw (0,0)--(0,1);
  \end{tikzpicture}
  \thepage\ 
  \begin{tikzpicture}
  \draw (0,0)--(0,1);
  \end{tikzpicture}}

I do get a warning that the use of fancyhdr with KOMA-Script is not recommended, but the document does compile. Maybe KOMA-Script already has a way to play around with headers, in which case maybe it's possible to add the TikZ code there. Also, I used Texmaker instead of LyX (I don't have much experience with it), but hopefully it works with LyX as well.

1
  • Thank you for your answer Janis, but I'm wary of using something that results in a warning. I will keep those fancyhdr and TikZ in mind in the future, though -- as they may have other abilities that the other solution does not.
    – Aces
    Commented Dec 26, 2016 at 23:46

You must log in to answer this question.

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