0

I am using fancyhdr package and unfortunately i am not able to put section name in header inside a mini page in my own defined \pagestyle.

For most pages i use \pagestyle{fancy}, but i have one page with a very long section name, so i thought i would create new \fancypagestyle and use \thispagestyle for the particular page to break text and make it a bit smaller.

This is what page with \pagestyle{fancy} looks like:

enter image description here

And this is what page with my defined \thispagestyle{} looks like, unfortunately it does not work for me as i dont see my section text in \rhead:

enter image description here

This is what i would like to achieve, i would also like to have the text in uppercase:

enter image description here

This is my defined style:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\graphicspath{ {./Obrazky/} }
\usepackage{fancyhdr}
\usepackage{xcolor}
\usepackage{titling}
\usepackage{array}
\setlength\headheight{26pt}
\lhead{\includegraphics[width=3cm]{newcevro}}

\usepackage{biblatex}
\addbibresource{Zdroje.bib}

\fancypagestyle{smallertextinheader}{ % Dokončit styl s menším textem v hlavičce
   \pagestyle{fancy}
   \fancyhf{}
   \fancyhead[LE,LO]{\includegraphics[width=3cm]{newcevro}}
   \fancyhead[RE,RO]{
   \begin{minipage}[b]{8cm}
   \small{
   \uppercase{\rightmark}}
   \end{minipage}}
}

This is what my normal page with a short section name looks like:

\newpage
\pagestyle{fancy}

\section{Systémové nedostatky a návrhy na řešení}

This is what my page with longer section name looks like:

\newpage

\thispagestyle{smallertextinheader}

\section{Komparace právní úpravy svěřenského fondu s právní úpravou dědictví}

I do not have that much experience with LaTeX and fancyhdr, what could i change to achieve what i need?

Thank you

2
  • Hello, thank you for your comment, i am sorry i do not entirely understand what you mean by that, i tried this: \newpage \thispagestyle{smallertextinheader} \section{Komparace právní úpravy svěřenského fondu s právní úpravou dědictví} \markright{\sectionmark{Some text}} but it still does not work for me, is adding \markright{\sectionmark{Some text}} what you meant by adding \markright to every section? Thank you
    – Raymond_90
    Jan 22, 2020 at 18:02
  • I can't find it, but evidently \section does define \leftmark (not \rightmark). Also, don't put \pagestyle(fancy} inside smallertextheader. Jan 22, 2020 at 18:29

1 Answer 1

0

Note that the bottom of the image is aligned with the baseline of the text. One can use \raisebox to lower the image by \dp\strutbox if so desired.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\graphicspath{ {./Obrazky/} }
\usepackage{fancyhdr}
\usepackage{xcolor}
\usepackage{titling}
\usepackage{array}
\setlength\headheight{26pt}
\lhead{\includegraphics[width=3cm,height=\dimexpr \headheight-\dp\strutbox]{example-image}}

\usepackage{biblatex}
\addbibresource{Zdroje.bib}

\fancypagestyle{smallertextinheader}{ % Dokončit styl s menším textem v hlavičce
   \fancyhf{}
   \fancyhead[LE,LO]{\includegraphics[width=3cm, height=\dimexpr \headheight-\dp\strutbox]{example-image}}
   \fancyhead[RE,RO]{%
   \parbox[b]{\dimexpr \textwidth-3cm-\columnsep}%
   {\small\uppercase\leftmark}}%
}
\pagestyle{fancy}
\begin{document}
\section{Systémové nedostatky a návrhy na řešení}
\clearpage% also flushes float queues

\thispagestyle{smallertextinheader}

\section{Komparace právní úpravy svěřenského fondu s právní úpravou dědictví}

\end{document}

Just for fun, here is a version which automatically switches if the normal title is too wide.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\graphicspath{ {./Obrazky/} }
\usepackage{xcolor}
\usepackage{titling}
\usepackage{array}
\usepackage{fancyhdr}
\setlength\headheight{26pt}
\lhead{\includegraphics[width=3cm,height=\dimexpr \headheight-\dp\strutbox]{example-image}}
\rhead{\sbox0{\textsl{\leftmark}}%
  \dimen0=\dimexpr\textwidth-3cm-\columnsep\relax
  \ifdim\wd0<\dimen0
    \usebox0
  \else
    \parbox[b]{\dimen0}{\hangindent=1.3em
      \small\textsl{\leftmark}}%
  \fi}
\usepackage{biblatex}
\addbibresource{Zdroje.bib}

\pagestyle{fancy}
\begin{document}
\section{Systémové nedostatky a návrhy na}

\clearpage% also flushes float queue
\section{Komparace právní úpravy svěřenského fondu s právní úpravou dědictví}

\end{document}
1
  • Works perfectly :-) Thank you very much, i marked your answer as a solution
    – Raymond_90
    Jan 22, 2020 at 19:22

You must log in to answer this question.

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