Page LayoutIssues with fancyhdr & newcommand for chapters

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
rocket2008
Posts: 2
Joined: Tue Feb 28, 2023 1:13 pm

Issues with fancyhdr & newcommand for chapters

Post by rocket2008 »

Hi, everyone!

I am using a newcommand to define how the chapters show up on the manuscript and ToC. That worked fine. Then, I wanted to place an image (logo) next to the page number in each page. It works, but I get the Missing $ inserted error for the lines where I make use of the newcommand (\mychapter) and for \end{document}.

Additionally, I want to align vertically the image with the page number. I tried with parbox but it didn't change anything.

Here is my MWE. In the original document (on Overleaf) I use input files and the error is the same.

Thanks for any tips.

Code: Select all

Code, edit and compile here:
\documentclass[11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[a4paper, total={170mm,257mm},
left=20mm,
top=20mm,]{geometry}
\usepackage{graphicx}
\usepackage{fancyhdr}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancypagestyle{plain}
{
\cfoot{ Page \thepage \ \vert \ \includegraphics[scale=0.1] {example-image-a}}
}
%%% change font %%%
\renewcommand{\sfdefault}{phv}
\renewcommand{\familydefault}{\sfdefault}
%%% set path of figures folder
\graphicspath{ {figures/} }
%%% packages %%%
\usepackage{enumitem}
\usepackage{float}
\usepackage{xcolor}
\usepackage{cancel}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{parskip}
\usepackage{svg}
\usepackage{accents}
\usepackage{mwe} % For dummy images
\usepackage{subcaption}
\usepackage{wrapfig}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

MjK
Posts: 89
Joined: Fri Jan 28, 2022 6:09 pm

Issues with fancyhdr & newcommand for chapters

Post by MjK »

\vert is a mathmode command. But instead of using $\vert$, I would suggest to use a \rule[<vertical shift>]{<width>}{<height>}.
My main topics are KOMA-Script and other questions related to my packages. If I reply to any other topic or if you've not yet added a minimal working example, please do not expect any further response. And please don't forget to tag examples as code.
rocket2008
Posts: 2
Joined: Tue Feb 28, 2023 1:13 pm

Issues with fancyhdr & newcommand for chapters

Post by rocket2008 »

Thank you very much, MjK. I hadn't thought of that. And your solution works perfectly. As for aligning the text and the image, I finally figured it out with \raisebox:

Code: Select all

{
\cfoot{ Page \thepage \ \ \rule[-0.2cm]{.05cm}{.8cm} \ \raisebox{-.2\height}{\includegraphics[scale=0.1]{example-image-a}}}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This is my first post asking for help on a forum, be it LaTex or some programming language. I am always amazed by how helpful people are, and receiving such a prompt response is shocking. Thank you.
Post Reply