5
  1. Here is a piece of solution to automate a dictionary using the links given in the first following comments.

    There are two problems to solve :

    • When one definition starts on one page and finishes on another, the words in the headinga are not the good ones. In my example below, take a look at the page 1 where the last word must be adhesive and not adhesion, and in the page 2, the first word must be adjacent and not adhesive. Is there a way to solve this problem ?
    • Secundly, I would like the letter A of the section to be centerd using \textbf{\textsf{...}} for formatting.

    Here is the code that I've wanted to improve.

    % Sources :
    %    1) http://tex.stackexchange.com/questions/30392/how-could-one-setup-a-layout-for-a-dictionary-if-possible
    %    2) http://tex.stackexchange.com/questions/26122/indexing-an-interval-of-words-on-top-of-every-page
    
    \documentclass[twoside]{article}
        \usepackage{multicol}
        \usepackage{ifthen}
        \usepackage{fancyhdr}
        \usepackage{enumerate}
        \usepackage{lipsum}
    
    % Empty \sectionmark
        \renewcommand{\sectionmark}[1]{}
    
        \fancyhead[L]{\textsf{\rightmark}}
        \fancyhead[R]{\textsf{\leftmark}}
        \fancyfoot[C]{\textbf{\textsf{\thepage}}}
    
    % Entry command : \dict{<word>}{<gender>}{<text>}
        \newcommand{\dict}[3]{%
            \par\vspace{0.25\baselineskip} %
            \textbf{\textsf{#1}} \textit{#2} #3 %
            \markboth{#1}{#1}
        }
    
        \pagestyle{fancy}
    
    
    \begin{document}
    
    \section*{A}
    
    \begin{multicols}{2}
        \dict{adequate}{n}{\lipsum[1]}
        \dict{adhere}{n}{\lipsum[2]}
        \dict{adherence}{n}{\lipsum[3]}
        \dict{adhesion}{n}{\lipsum[4]}
        \dict{adhesive}{n}{\lipsum[5]}
        \dict{adjacent}{n}{\lipsum[6]}
        \dict{adjective}{n}{\lipsum[1]}
        \dict{adjoin}{n}{\lipsum[2]}
        \dict{adjourn}{n}{\lipsum[3]}
        \dict{adjournment}{n}{\lipsum[4]}
        \dict{adjunt}{n}{\lipsum[5]}
        \dict{adjust}{n}{\lipsum[6]}
    \end{multicols}
    
    \end{document}
    
  2. The solution found is the following one even if there is one remaining disturbing behavior, even if it is logical : in the last page of the output of the following code, zero appears in both headers...

    % Sources :
    %    1) http://tex.stackexchange.com/questions/30392/how-could-one-setup-a-layout-for-a-dictionary-if-possible
    %    2) http://tex.stackexchange.com/questions/26122/indexing-an-interval-of-words-on-top-of-every-page
    %    3) http://tex.stackexchange.com/questions/30947/how-to-automate-a-dictionary-sorting-headers/31017#31017
    
    \documentclass[twoside]{article}
        \usepackage{multicol}
        \usepackage{fancyhdr}
        \usepackage[bf,sf,center]{titlesec}
    
    % Headers and footers
        \fancyhead[L]{\textsf{\rightmark}}
        \fancyhead[R]{\textsf{\leftmark}}
    
        \fancyfoot[C]{\textbf{\textsf{\thepage}}}
    
        \renewcommand{\headrulewidth}{1.4pt}
        \renewcommand{\footrulewidth}{1.4pt}
    
    % Entry command : \dict{<word>}{<gender>}{<text>}
        \newcommand{\dict}[3]{%
            \markboth{#1}{#1}%
            \par\vspace{0.25\baselineskip}%
            \textbf{\textsf{#1}} \textit{- #2 -} #3%
        }
    
        \pagestyle{fancy}
    
    % For testing
        \usepackage{lipsum}
    
    
    \begin{document}
    
    \section*{A}
    
    \begin{multicols}{2}
        \dict{adequate}{n}{\lipsum[1]}
        \dict{adhere}{n}{\lipsum[2]}
        \dict{adherence}{n}{\lipsum[3]}
        \dict{adhesion}{n}{\lipsum[4]}
        \dict{adhesive}{n}{\lipsum[5]}
        \dict{adjacent}{n}{\lipsum[6]}
        \dict{adjective}{n}{\lipsum[1]}
        \dict{adjoin}{n}{\lipsum[2]}
        \dict{adjourn}{n}{\lipsum[3]}
        \dict{adjournment}{n}{\lipsum[4]}
        \dict{adjunt}{n}{\lipsum[5]}
        \dict{adjust}{n}{\lipsum[6]}
    \end{multicols}
    
    
    \section*{M}
    
    \begin{multicols}{2}
        \dict{main}{n}{\lipsum[3]}
        \dict{material}{n}{\lipsum[1]}
        \dict{mathematic}{n}{\lipsum[2]}
        \dict{more}{n}{\lipsum[2]}
    \end{multicols}
    
    
    \section*{Z}
    
    \begin{multicols}{2}
        \dict{zebra}{n}{\lipsum \lipsum \lipsum}
        \dict{zero}{n}{\lipsum[4]}
    \end{multicols}
    
    \end{document}
    
lockstep
  • 250,273
projetmbc
  • 13,315
  • Did you see my comment on the original question (duplicated here): For adding a dictionary-style running head that shows the first/last entry per page, it would be easiest to input the dictionary items (\dict in @Tobi's answer) as some form of sectional command (like subsubsection, say). Then it should be possible to use information contained in Chapters and verses of current page in header to update these running headers automatically via the titlesec package. – Werner Oct 08 '11 at 18:16
  • 1
    Does this post help: http://tex.stackexchange.com/questions/26122/indexing-an-interval-of-words-on-top-of-every-page – cmhughes Oct 08 '11 at 18:34
  • cmhughes, thanks for the link. I'll try to mix this solution with the one above. – projetmbc Oct 09 '11 at 10:27
  • 2
    There's no need to edit the question title with (SOLVED). You already "marked" the question this way by accepting an answer. – lockstep Oct 09 '11 at 12:42
  • 2
    I reverted your question to version 3, the one before your problem was solved. This way, other users can see what the original problem was and what you were looking for. If the solution you eventually used differs decisively from lockstep's, you're welcome to add an answer of your own. If you just want to comment on the way you used it, add a comment to lockstep's answer. – doncherry Oct 09 '11 at 12:47
  • 1
    With regard to your latest question: You need to figure out what your requirements exactly are. If zebra should replace zero on the last page, why shouldn't adhesive replace adjacent on the second page? – lockstep Oct 09 '11 at 13:21
  • 1
    Thank you for being so patient in dealing with this site's habits in terms of what belongs where. You'll soon get the hang of it, as I hope you'll stick around -- I really like your question and the dictionary looks great! – doncherry Oct 09 '11 at 13:23
  • lockstep, you're right, my question is not so logic. I will change the way I've witten things. doncherry, I hope to find the power of the force one day (for the moment, I'm just struggling with my english writing...). – projetmbc Oct 09 '11 at 13:25
  • Instead of describing behaviour as "disturbing, even if logical", you should describe the desired behaviour. – lockstep Oct 09 '11 at 13:42
  • The actual behavior is logical, so I will accept it. – projetmbc Oct 09 '11 at 13:53

1 Answers1

4

With regard to your first question (wrong header entries): In your \dict macro, use \markboth before typesetting the entry text.

\newcommand{\dict}[3]{%
  \markboth{#1}{#1}%
  \par\vspace{0.25\baselineskip}%
  \textbf{\textsf{#1}} \textit{#2} #3%
}

With regard to your second question (formatting the sectioning heading): Use, e.g.,

\usepackage[bf,sf,center]{titlesec}
lockstep
  • 250,273