3

So I am trying to create a dictionary, I have mostly everything worked out except for that signature dictionary style header where the first and last word of the page are displayed in the header.

I am using a sort environment (see here) to alphabetically sort 3 different defined commands: \wn, \wv, and \wa (for nouns, verbs, and adjectives, respectively) which are how my entries are stored.

I cannot figure out how to have the first and final entries of each page be properly 'marked' for fancyhdr to utilize in the header. I've tried using \markboth{1}{1} in all 3 of the defined commands, however that doesn't work.

MWE:

\documentclass[11pt,twoside]{article}
\usepackage[paperheight=9in,paperwidth=6in,bottom=1in]{geometry}
\usepackage{multicol} 
\usepackage{fancyhdr}
\usepackage{datatool}
\usepackage{fix2col}

%Command Setups

\newcommand{\wn}[5]{%
    \markboth{#1}{#1}
    \DTLnewrow{list}%
    \DTLnewdbentry{list}{label}{#1}%
    \DTLnewdbentry{list}{description}{\textit{\textsc{{\footnotesize n.}}} \textbf{#2} }
    \DTLnewdbentry{list}{ipa}{(#3) }%
    \DTLnewdbentry{list}{plural}{\textit{pl.\hspace{2pt}#4 }}%
    \DTLnewdbentry{list}{extra}{#5}%
}
\newcommand{\wv}[4]{%
    \markboth{#1}{#1}
    \DTLnewrow{list}%
    \DTLnewdbentry{list}{label}{#1}%
    \DTLnewdbentry{list}{description}{\textit{\textsc{{\footnotesize v.}}} \textbf{#2} }
    \DTLnewdbentry{list}{ipa}{(#3) }%
    \DTLnewdbentry{list}{plural}{}%
    \DTLnewdbentry{list}{extra}{#4}%
}
\newcommand{\wa}[4]{%
    \markboth{#1}{#1}
    \DTLnewrow{list}%
    \DTLnewdbentry{list}{label}{#1}%
    \DTLnewdbentry{list}{description}{\textit{\textsc{{\footnotesize adj.}}} \textbf{#2} }
    \DTLnewdbentry{list}{ipa}{(#3) }%
    \DTLnewdbentry{list}{plural}{}%
    \DTLnewdbentry{list}{extra}{#4}%
}

%Enviroment Setup

\newenvironment{sortedlist}%
{%
    \DTLifdbexists{list}{\DTLcleardb{list}}{\DTLnewdb{list}}%
}%
{%
    \DTLsort{label}{list}%
    \begin{description}%
        \DTLforeach*{list}{\theLabel=label,\theDesc=description,\theIp=ipa,\thePl=plural,\theEx=extra}{%
            \item[\theLabel] \theDesc \theIp \thePl \theEx
        }%
    \end{description}% 
}

\begin{document}
    \pagestyle{fancy}
    \fancyhf{}
    \fancyhead[LE,LO]{\textsc{\rightmark}}
    \fancyhead[CO,CE]{\thepage}
    \fancyhead[RE,RO]{\textsc{\leftmark}}
    \begin{flushleft}
        \begin{multicols}{2}\hangindent=3pt\setlength{\columnseprule}{.5pt}
            \raggedright
            \begin{sortedlist}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
            \end{sortedlist}
        \end{multicols}
    \end{flushleft}
\end{document}
Manofzelego
  • 169
  • 1
  • 2
  • 11

1 Answers1

3

Here is an answer. Don't use \markboth{#1}{#1} within creating database command but in loading the sorted base

 \DTLsort{label}{list}%
    \begin{description}%
        \DTLforeach*{list}{\theLabel=label,\theDesc=description,\theIp=ipa,\thePl=plural,\theEx=extra}{%
    \markboth{\theLabel}{\theLabel}%
    \item[\theLabel] \theDesc \theIp \thePl \theEx
        }%
    \end{description}% 

MWE

\documentclass[11pt,twoside]{article}
\usepackage[paperheight=9in,paperwidth=6in,bottom=1in]{geometry}
\usepackage{multicol} 
\usepackage{fancyhdr}
\usepackage{datatool}
\usepackage{fix2col}

%Command Setups

\newcommand{\wn}[5]{%
    \DTLnewrow{list}%
    \DTLnewdbentry{list}{label}{#1}%
    \DTLnewdbentry{list}{description}{\textit{\textsc{{\footnotesize n.}}} \textbf{#2} }
    \DTLnewdbentry{list}{ipa}{(#3) }%
    \DTLnewdbentry{list}{plural}{\textit{pl.\hspace{2pt}#4 }}%
    \DTLnewdbentry{list}{extra}{#5}%
}
\newcommand{\wv}[4]{%
    \DTLnewrow{list}%
    \DTLnewdbentry{list}{label}{#1}%
    \DTLnewdbentry{list}{description}{\textit{\textsc{{\footnotesize v.}}} \textbf{#2} }
    \DTLnewdbentry{list}{ipa}{(#3) }%
    \DTLnewdbentry{list}{plural}{}%
    \DTLnewdbentry{list}{extra}{#4}%
}
\newcommand{\wa}[4]{%
    \DTLnewrow{list}%
    \DTLnewdbentry{list}{label}{#1}%
    \DTLnewdbentry{list}{description}{\textit{\textsc{{\footnotesize adj.}}} \textbf{#2} }
    \DTLnewdbentry{list}{ipa}{(#3) }%
    \DTLnewdbentry{list}{plural}{}%
    \DTLnewdbentry{list}{extra}{#4}%
}

%Enviroment Setup

\newenvironment{sortedlist}%
{%
    \DTLifdbexists{list}{\DTLcleardb{list}}{\DTLnewdb{list}}%
}%
{%
    \DTLsort{label}{list}%
    \begin{description}%
        \DTLforeach*{list}{\theLabel=label,\theDesc=description,\theIp=ipa,\thePl=plural,\theEx=extra}{%
    \markboth{\theLabel}{\theLabel}\item[\theLabel] \theDesc \theIp \thePl \theEx
        }%
    \end{description}% 
}

\begin{document}
    \pagestyle{fancy}
    \fancyhf{}
    \fancyhead[LE,LO]{\textsc{\rightmark}}
    \fancyhead[CO,CE]{\thepage}
    \fancyhead[RE,RO]{\textsc{\leftmark}}
    \begin{flushleft}
        \begin{multicols}{2}\hangindent=3pt\setlength{\columnseprule}{.5pt}
            \raggedright
            \begin{sortedlist}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
                \wv{B}{b}{b}{the second letter of the alphabet}
                \wa{C}{c}{c}{the third letter of the alphabet}
                \wn{A}{a}{a}{as}{the first letter of the alphabet}
            \end{sortedlist}
        \end{multicols}
    \end{flushleft}
\end{document}

enter image description here

touhami
  • 19,520