7

I use fancyhdr to display first and last headword from my dictionary in the header section. The problem is that the headwords in the dictionary may contain special symbols (see example picture)Headwords in header section) that I do not want to appear in the header line. How can I display headwords without symbols in the header line?

Here comes the minimum example:

\documentclass[twocolumn]{book}
\usepackage[margin=2cm]{geometry}
\usepackage[icelandic, czech, english]{babel}
\usepackage[utf8x,utf8]{inputenc}
\usepackage[T1]{fontenc}
\newcommand{\entry}[2]{\hangpara{2em}{1}\textsf{\textbf{#1}}\ 
    #2\markboth{#1}{#1}\par}\nopagebreak[4]
\usepackage{fix2col,hanging}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancypagestyle{dictstyle}{%
    \fancyhf{}
    \fancyhead[LE,RO]{\textsf{\textbf{\rightmark\ -- \leftmark}}}
    \fancyhead[LO,RE]{\textsf{\textbf{\thepage}}}
}

\begin{document} 
\pagestyle{dictstyle}
\entry{kímni··gáf|a}{meaning}
\end{document}
chejnik
  • 1,441
  • 2
  • 23
  • 42
  • 1
    I've edited your MWE to make it compilable (one needs to load the hanging package) and for semantics (e.g., "header section" versus "header line". Unfortunately, your MWE doesn't actually contain any "unusual characters" that might need to be simplified or suppressed for display in the header line. Please consider editing your MWE to introduce some actual "problem words". – Mico Feb 07 '12 at 13:54
  • Thank you Mico for hints. I have edited my question and set headword with special symbols. – chejnik Feb 07 '12 at 14:04

1 Answers1

8

you can define an optional argument for \entry which is always used for the word without symbols:

\entry[word without symbols]{word with symbols}{meaning}
\entry{word without symbols}{meaning}

\documentclass[twocolumn]{book}
\usepackage[margin=2cm]{geometry}
\usepackage[icelandic, czech, english]{babel}
\usepackage[utf8x,utf8]{inputenc}
\usepackage[T1]{fontenc}
\newcommand\entry[3][]{\hangpara{2em}{1}\textsf{\textbf{#2}}\ 
    #3\ifx\relax#1\relax\markboth{#2}{#2}\else\markboth{#1}{#1}\fi
    \par}\nopagebreak[4]
\usepackage{fix2col,hanging}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancypagestyle{dictstyle}{%
    \fancyhf{}
    \fancyhead[LE,RO]{\textsf{\textbf{\rightmark\ -- \leftmark}}}
    \fancyhead[LO,RE]{\textsf{\textbf{\thepage}}}
}

\begin{document} 
\pagestyle{dictstyle}
\entry[kímnigáfa]{kímni··gáf|a}{meaning}
\entry{word without symbols}{meaning}
\entry[word without symbols]{word$\cdot$symbols}{meaning}
\clearpage
\entry[word without symbols]{word:symbols}{meaning}
\entry{word}{meaning}
\end{document}