定义多个输入命令的字典样式 Fancyhdr 标题

定义多个输入命令的字典样式 Fancyhdr 标题

因此,我正在尝试创建一本字典,除了签名字典样式的标题(其中页面的第一个和最后一个单词显示在标题中)之外,我基本上已经完成了所有工作。

我正在使用排序环境(请参阅这里)按字母顺序对 3 个不同的定义命令进行排序:\wn、、\wv\wa(分别用于名词、动词和形容词),这就是我的条目的存储方式。

我不知道如何正确“标记”每页的第一个和最后一个条目,以便fancyhdr在页眉中使用。我尝试使用\markboth{1}{1}所有 3 个定义的命令,但不起作用。

梅威瑟:

\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}

答案1

答案如下。不要\markboth{#1}{#1}在创建数据库命令中使用,而是在加载排序的基础中使用

 \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}% 

平均能量损失

\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}

在此处输入图片描述

相关内容