Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
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 7 '12 at 13:54
    
Thank you Mico for hints. I have edited my question and set headword with special symbols. –  chejnik Feb 7 '12 at 14:04
add comment

1 Answer 1

up vote 8 down vote accepted

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}
share|improve this answer
    
Thank you. It works :) –  chejnik Feb 7 '12 at 15:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.