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.

EDIT: I've edited the code that reproduces the anomalies, but I'll work on the code to more accurately depict the problem later on the day.

  1. Weird spacing in index
  2. Index doesn't appear in footlinks / isn't recognised as a section

The code won't show properly on this page (somehow 4 spaces doesn't do the trick), so I pasted it here.


I'm trying to create a macro to save the name of the previous and next section automatically, so I can reuse it in my footer (with a link, but that's easily done through \hyperlink{page.\getpagerefnumber{<anchor>}} and anchors).

See the rfoot with the hyperlinks to different appendices.

MWE:

\documentclass{article} 

\usepackage{marginnote}
\usepackage{pbox}
\usepackage[heightrounded]{geometry}
\usepackage{lastpage}
\usepackage[toc,titletoc,page]{appendix}

% Set some commands that I'll use for all footers
\usepackage{fancyhdr}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{.4pt}

% Command for pageref for page/LastPage in footer
\cfoot{\thepage /\pageref{LastPage}\hyperlink{page.\getpagerefnumber{anchor.lastpage}}{ $\rightarrow$}}

% Global pagestyle commands
\fancypagestyle{contents}{
\lfoot{\textbf{Inhoudsopgave}}
}
\fancypagestyle{document}{
                    \rfoot{\hyperlink{document.toc}{$\leftarrow$ Naar inhoudsopgave}}
                    \lfoot{\currentsection}
}

% By declaring the plain pagestyle explicitly, the first page is forced in terms of header and footer settings
% Not declaring this page style will not apply fancyhdr settings to the first page
\fancypagestyle{plain}{
\lhead{}
\chead{}
\rhead{}
\lfoot{\textbf{Inhoudsopgave}}
\cfoot{\thepage /\pageref{LastPage}\hyperlink{page.\getpagerefnumber{anchor.lastpage}}{ $\rightarrow$}}
\rfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}
}

% header dummies which will be used in appendices - Auto-adjustment for variable page print of appendices
% It's also possible to use \getpagerefnumber and link thereto, but that gets you to the top of the page rather than the top of the appendix
% It's a small difference, but this yields a (slightly) prettier result
\fancypagestyle{a.appendix.headerref}{
                    \rfoot{\pbox{5cm}{\hyperlink{document.toc}{$\leftarrow$ Naar inhoudsopgave} \\ \hyperlink{appendix.b}{Naar begrippenlijst $\rightarrow$}  \\ \hyperlink{appendix.c}{Naar Index $\rightarrow$ }}}% 
                    \lfoot{\currentsection}
                    \fancyhead[C]{\hypertarget{appendix.a}{}}
}
\fancypagestyle{b.appendix.headerref}{
                    \rfoot{\pbox{5cm}{\hyperlink{document.toc}{$\leftarrow$ Naar inhoudsopgave} \\ \hyperlink{appendix.a}{$\leftarrow$ Naar \textbf{\textcolor{blue}{R}} commando's} \\ \hyperlink{appendix.c}{Naar Index $\rightarrow$ }}}% 
                    \fancyhead[C]{\hypertarget{appendix.b}{}}
}
\fancypagestyle{c.appendix.headerref}{
                    \rfoot{\pbox{5cm}{\hyperlink{document.toc}{$\leftarrow$ Naar inhoudsopgave} \\ \hyperlink{appendix.b}{$\leftarrow$ Naar begrippenlijst} \\ \hyperlink{appendix.d}{Naar Nesting $\rightarrow$ }}}%
                    \fancyhead[C]{\hypertarget{appendix.c}{}}
}
\fancypagestyle{d.appendix.headerref}{
                    \rfoot{\pbox{5cm}{\hyperlink{document.toc}{$\leftarrow$ Naar inhoudsopgave} \\ \hyperlink{appendix.b}{$\leftarrow$ Naar begrippenlijst } \\ \hyperlink{appendix.c}{$\leftarrow$ Naar Index }}}%
                    \fancyhead[C]{\hypertarget{appendix.d}{}}
}

\fancypagestyle{a.appendix.sep}{
                    \rfoot{\pbox{5cm}{\hyperlink{document.toc}{$\leftarrow$ Naar inhoudsopgave} \\ \hyperlink{appendix.b}{Naar begrippenlijst $\rightarrow$}  \\ \hyperlink{appendix.c}{Naar Index $\rightarrow$ }}}% 
                    \lfoot{\currentsection}
                    \fancyhead[C]{} % Reset the header from headerref construction
}
\fancypagestyle{b.appendix.sep}{
                    \rfoot{\pbox{5cm}{\hyperlink{document.toc}{$\leftarrow$ Naar inhoudsopgave} \\ \hyperlink{appendix.a}{$\leftarrow$ Naar \textbf{\textcolor{blue}{R}} commando's} \\ \hyperlink{appendix.c}{Naar Index $\rightarrow$ }}}% 
                    \lfoot{\currentsection}
                    \fancyhead[C]{} 
}
\fancypagestyle{c.appendix.sep}{
                    \rfoot{\pbox{5cm}{\hyperlink{document.toc}{$\leftarrow$ Naar inhoudsopgave} \\ \hyperlink{appendix.b}{$\leftarrow$ Naar begrippenlijst} \\ \hyperlink{appendix.d}{Naar Nesting $\rightarrow$ }}}%
                    \lfoot{\currentsection}
                    \fancyhead[C]{}
}
\fancypagestyle{d.appendix.sep}{
                    \rfoot{\pbox{5cm}{\hyperlink{document.toc}{$\leftarrow$ Naar inhoudsopgave} \\ \hyperlink{appendix.b}{$\leftarrow$ Naar begrippenlijst } \\ \hyperlink{appendix.c}{$\leftarrow$ Naar Index }}}%
                    \lfoot{\currentsection}
                    \fancyhead[C]{}
}



% Cross-references
\usepackage[pageanchor]{hyperref}
\hypersetup{colorlinks=true,
        linkcolor=red,
        hypertexnames=false,
        pdfhighlight=/N,
        pdfstartview={XYZ null null 1.00}
        }

\title{}
\author{}
\date{}

\begin{document}

\pagestyle{contents}
\hypertarget{document.toc}{}
\maketitle
\tableofcontents

% Footer section name - Declare after ToC to keep section numbering intact
\newcommand{\currentsection}{}
\let\oldsection\section
\renewcommand{\section}[1]{\oldsection{#1}\renewcommand{\currentsection}{#1}}

\newpage

\pagestyle{document}
\section{Week 1 - Intro \textcolor{blue}{\textbf{R}}}
\subsection{Objecten}
\subsubsection{Objecten met \'e\'en getal}

\newpage

% Clearpage to move floats as well, use newpage if you don't have floats on the last page
\clearpage
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
\begin{appendices}
\addtocontents{toc}{\protect\setcounter{tocdepth}{1}}

% I am using hypertargets from the preamble to make sure hyperref takes you to the top of the page and not the middle of it
% I've already explained why I picked this solution over \getpagerefnumber
\pagestyle{a.appendix.headerref}
\section{\textbf{\textcolor{blue}{R} commando's}}

text

\newpage

\section{\textbf{Begrippenlijst}}
\pagestyle{b.appendix.headerref}

\newpage

\pagestyle{c.appendix.headerref}
\section{\textbf{Index}}

text

\newpage

\section{\textbf{Nesting}}

text

\end{appendices}

% Because the footer is printed last and there is a space between the appendices environment and the end of the document, we have to force this value or define set a manual environment. Setting a new environment would be the more tedious solution
                    \rfoot{\pbox{5cm}{\hyperlink{document.toc}{$\leftarrow$ Naar inhoudsopgave} \\ \hyperlink{appendix.b}{$\leftarrow$ Naar begrippenlijst } \\ \hyperlink{appendix.c}{$\leftarrow$ Naar Index }}}%
                    \lfoot{\textbf{Nesting}} % This will have to be set manually to circumvent cross-environment anomalies with fancyhdr
                    \lhead{}
                    \fancyhead[C]{\hypertarget{appendix.d}{}}

% Anchor on last page
\label{anchor.lastpage}

\end{document}
share|improve this question
    
I believe you have to catch the \section command and grab the section title in order to store it to some \gdefed command. –  Christian Hupfer May 3 at 18:06
    
Maybe it is just me but having compiled this I have no idea what it is supposed to look like or (therefore) what the problem is supposed to be. Is the issue specific to appendices? I'm assuming yes else you wouldn't have them in a minimal example but I just find it confusing. (Probably not helped by not understanding the language, mind.) –  cfr May 3 at 22:43
    
@cfr I want to automate creation of a dynamic footer which allows the user to navigate with hyperlinks through the appendix –  1010011010 May 4 at 0:08
    
How is that code supposed to do that? I don't see how you are using \oldsection or which parts of that are meant to be relevant. You use a custom pagestyle for each appendix. I don't understand how the other one you define is supposed to be used or how that one is meant to work with \oldsection etc.? –  cfr May 4 at 1:26

1 Answer 1

up vote 8 down vote accepted
+150

Improved version

I made some kind of a hack, redefining the \section command and introducing the possibility to refer to the previous and next section title name as hyperlinks. The titles are inserted automatically.

\documentclass[paper=a4,12pt,onesided]{scrartcl}
\usepackage{blindtext}
\usepackage{everypage}
\usepackage{lastpage}%
\usepackage{xcolor}%
\usepackage{imakeidx}%
\usepackage[heightrounded]{geometry}%
\usepackage[toc,titletoc,page]{appendix}%

\usepackage{etoolbox}
\usepackage{bbding}

\usepackage[pageanchor]{hyperref}%

\newrobustcmd{\ProvideBool}[2][false]{%
\newbool{#2}%
\setbool{#2}{#1}%
}%


\ProvideBool[true]{DocumentSectionAutoClearpage}%

\newrobustcmd{\EnableSectionAutoClearpage}{%
\setbool{DocumentSectionAutoClearpage}{true}%
}%

\newrobustcmd{\DisableSectionAutoClearpage}{%
\setbool{DocumentSectionAutoClearpage}{false}%
}%


\definecolor{DocumentHyperLinkColor}{RGB}{255,0,0}%


\hypersetup{colorlinks=true,
        linkcolor=DocumentHyperLinkColor,
        hypertexnames=false,
        pdfhighlight=/N,
        pdfstartview={XYZ null null 1.00}
        }


\AtBeginDocument{%
\setcounter{PrintIndexSectionCounter}{\number\value{IndexSectionCounterValue}}
\EnableSectionAutoClearpage%
}%



\makeatletter
\let\LaTeXStandardSection\section


% Providing section command with no optional argument

\newrobustcmd{\improvedstarredsection}[1]{% 
% No name reference to unnumbered sections 
%\BeforeSectionStarts{#1}%
\LaTeXStandardSection*{#1}%
}%



\newrobustcmd{\improvedsection@noopt}[1]{%
\BeforeSectionStarts{#1}%
\LaTeXStandardSection{#1}%
}%





% Providing section command with an optional argument
\newrobustcmd{\improvedsection@opt}[2][]{%
\BeforeSectionStarts{#1}%
\LaTeXStandardSection[#1]{#2}%
}%


% "True" section command
\newrobustcmd{\improvedsection}{%
\ifboolexpr{bool{DocumentSectionAutoClearpage}}{\clearpage}{}
\@ifnextchar[{\improvedsection@opt}{\improvedsection@noopt}
}%




%%%%%% Use the 'improved' section commands with forward/backward links
\renewcommand{\section}{%
\@ifstar{\improvedstarredsection}{\improvedsection}%
}
\makeatother




\makeatletter
\renewenvironment{theindex}{%
 \if@twocolumn
 \@restonecolfalse
 \else
 \@restonecoltrue
 \fi
 \phantomsection%
  \section{\indexname}%
  \setcounter{PrintIndexSectionCounter}{\number\value{CurrentSectionCounter}}%
  \@mkboth{\MakeUppercase\indexname}%
  {\MakeUppercase\indexname}%
  \parindent\z@
  % \thispagestyle{plain}\parindent\z@
  \parskip\z@ \@plus .3\p@\relax
  \columnseprule \z@
  \columnsep 35\p@
  \let\item\@idxitem}
{\if@restonecol\onecolumn\else\clearpage\fi}%
\makeatother



\makeatletter
\newrobustcmd{\LastSectionInFile}{%
   \immediate\write\@auxout{\string
     \setcounter{LastSectionValue}{\number\value{CurrentSectionCounter}}%
   }%
}

\newrobustcmd{\IndexSectionInFile}{%
   \immediate\write\@auxout{\string
     \setcounter{IndexSectionCounterValue}{\number\value{PrintIndexSectionCounter}}%
   }%
}%



\makeatother

\AtEndDocument{%
\LastSectionInFile%
\IndexSectionInFile%
}%

\newrobustcmd{\PreviousSectionName}{\refcommand{CurrentSection::Title::\number\value{PreviousSectionCounter}}}%
\newrobustcmd{\CurrentSectionName}{\refcommand{CurrentSection::Title::\number\value{CurrentSectionCounter}}}%
\newrobustcmd{\NextSectionName}{\refcommand{CurrentSection::Title::\number\value{NextSectionCounter}}}%
\newrobustcmd{\NextSectionHyperLinkFormat}[1]{#1}%
\newrobustcmd{\PreviousSectionHyperLinkFormat}[1]{#1}%






\newrobustcmd{\GenerateNextSectionHyperlink}[3]{%
\DoIfNumInequal{\number\value{#1}}{\number\value{#3}}{%
\DoIfNumNotZero{\number\value{PrintIndexSectionCounter}}{%
    % Only set a link of the next section is not the index section%
  \ifnumequal{\number\value{#1}+1}{\number\value{PrintIndexSectionCounter}}{%
  \setcounter{InternalTitleCounter}{\number\value{#2}}%
  \addtocounter{InternalTitleCounter}{1}%
  \hyperlink{CurrentSection::\number\value{InternalTitleCounter}}{\NextSectionHyperLinkFormat{\refcommand{CurrentSection::Title::\number\value{InternalTitleCounter}}}}%
  }{
    \hyperlink{CurrentSection::\number\value{#2}}{\NextSectionHyperLinkFormat{\refcommand{CurrentSection::Title::\number\value{#2}}}}%
  }}%
{%
  \hyperlink{CurrentSection::\number\value{#2}}{\NextSectionHyperLinkFormat{\refcommand{CurrentSection::Title::\number\value{#2}}}}%
  }%
  }% End of inner \DoIfNumInEqual
}%

\newrobustcmd{\GeneratePreviousSectionHyperlink}[3]{%
\DoIfNumInequal{\number\value{#1}}{1}{%
\DoIfNumNotZero{\number\value{PrintIndexSectionCounter}}{%
\ifnumequal{\number\value{#1}-1}{\number\value{PrintIndexSectionCounter}}{%
  \setcounter{InternalTitleCounter}{\number\value{#2}}%
  \addtocounter{InternalTitleCounter}{-1}%
  \hyperlink{CurrentSection::\number\value{InternalTitleCounter}}{\PreviousSectionHyperLinkFormat{\refcommand{CurrentSection::Title::\number\value{InternalTitleCounter}}}}%
}{
%  \DoIfNumInequal{\number\value{#1}-1}{\number\value{PrintIndexSectionCounter}}{%
    \hyperlink{CurrentSection::\number\value{#2}}{\PreviousSectionHyperLinkFormat{\refcommand{CurrentSection::Title::\number\value{#2}}}}%
  }%
}{%
% Insert link in any case, since there is no bottom `Index` link
  \hyperlink{CurrentSection::\number\value{#2}}{\PreviousSectionHyperLinkFormat{\refcommand{CurrentSection::Title::\number\value{#2}}}}%
}%
}% End of outer \DoIfNumInequal
}% End of command



\newrobustcmd{\GenerateArrowHyperlinkToNextSection}[3]{%
\DoIfNumInequal{\number\value{#1}}{\number\value{#3}}{%
\DoIfNumNotZero{\number\value{PrintIndexSectionCounter}}{%
  \ifnumequal{\number\value{#1}+1}{\number\value{PrintIndexSectionCounter}}{%
    \setcounter{InternalTitleCounter}{\number\value{#2}}%
    \addtocounter{InternalTitleCounter}{1}% Look ahead
    \hyperlink{CurrentSection::\number\value{InternalTitleCounter}}{\ToNextSectionSymbol}%
    }{%
     \hyperlink{CurrentSection::\number\value{#2}}{\ToNextSectionSymbol}%
    }%%
}{%
  \hyperlink{CurrentSection::\number\value{#2}}{\ToNextSectionSymbol}%
}%
}% End of outer \DoIfNumInEqual
}%

\newrobustcmd{\GenerateArrowHyperlinkToPreviousSection}[3]{%
\DoIfNumInequal{\number\value{#1}}{1}{%
% But do nothing if the section number is equal to the total section counter value
\DoIfNumNotZero{\number\value{#1}}{%
\ifnumequal{\number\value{#1}-1}{\number\value{PrintIndexSectionCounter}}{%
  \setcounter{InternalTitleCounter}{\number\value{#1}}%
  \addtocounter{InternalTitleCounter}{-2}% Look ahead
  \hyperlink{CurrentSection::\number\value{InternalTitleCounter}}{\ToPreviousSectionSymbol}%
}{%
\hyperlink{CurrentSection::\number\value{#2}}{\ToPreviousSectionSymbol}%
}%
}{%
\hyperlink{CurrentSection::\number\value{#2}}{\ToPreviousSectionSymbol}%
}%
}% End of outer \DoIfNumInequal
}% End of command


\renewcommand{\indexname}{Index}
\renewcommand{\contentsname}{Inhoudsopgave}
\newcommand{\LinkToContentsName}{\contentsname}
\newcommand{\LinkToIndexName}{Index}


\newrobustcmd{\DoIfNumNotZero}[3]{%
\ifnumequal{#1}{0}{#3}{#2}%
}%


\newrobustcmd{\DoIfNumInequal}[3]{%
\ifnumequal{#1}{#2}{}{#3}%
}%

\newrobustcmd{\IfNumInequal}[4]{%
\ifnumequal{#1}{#2}{#3}{#4}%  
}%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%Additional counters%%%%


\newcounter{LastDocumentPageCounter}%
\setcounter{LastDocumentPageCounter}{1}

\newcounter{IndexSectionCounterValue}%
\newcounter{PrintIndexSectionCounter}%




\newcounter{PreviousSectionCounter}% No resetting%%%
\setcounter{PreviousSectionCounter}{0}%

\newcounter{NextSectionCounter}% No resetting%%%
\setcounter{NextSectionCounter}{0}


\newcounter{CurrentSectionCounter}% No resetting%%%
\setcounter{CurrentSectionCounter}{0}

\newcounter{LastSectionValue}

\newcounter{InternalTitleCounter}

\newrobustcmd{\refcommand}[1]{%
\nameref*{#1}%
}%



\newrobustcmd{\CurrentSectionSymbol}{\textbf{\textcolor{blue}{\HandRight}}~}
\newrobustcmd{\ToNextSectionSymbol}{\textbf{\textcolor{DocumentHyperLinkColor}{\HandRight}}~}
\newrobustcmd{\ToPreviousSectionSymbol}{\textbf{\textcolor{DocumentHyperLinkColor}{\HandLeft}}~}



\makeatletter

\newrobustcmd{\WriteUniqueTextLabelContent}[2]{%
\immediate\write\@auxout{%
\string\newlabel{#1}{{\thesection}{\thepage}{\unexpanded{#2}}{}}%
}%
}%

\newrobustcmd{\BeforeSectionStarts}[1]{%
\stepcounter{CurrentSectionCounter}%
%%%%% Check first whether there is already a previous section
\ifnumequal{\number\value{CurrentSectionCounter}}{1}{% Yes, section number is zero
\setcounter{PreviousSectionCounter}{1}%
}{%
\setcounter{PreviousSectionCounter}{\number\value{CurrentSectionCounter}}
\addtocounter{PreviousSectionCounter}{-1}
}
% CurrentSectionCounter > 1
% Set Target to current section
\phantomsection
\hypertarget{CurrentSection::\number\value{CurrentSectionCounter}}{}%
\WriteUniqueTextLabelContent{CurrentSection::Title::\number\value{CurrentSectionCounter}}{#1}%
% Set correct numbers 
\setcounter{NextSectionCounter}{\number\value{CurrentSectionCounter}}
\ifnumequal{\number\value{CurrentSectionCounter}}{\number\value{LastSectionValue}}{}{%
\addtocounter{NextSectionCounter}{1}%
}%
\phantomsection
}%


\newrobustcmd{\InsertToIndexSymbol}[4]{%
% #1: Number of IndexSection
% #2: Number of CurrentSection
% #3: Text for link to previous section (normally left hand?)
% #4: Text for link to next section (normally right hand?)
\ifnumequal{\number\value{#1}}{0}{%
% Do nothing, since there is no Index section (value of #1)!
}{%
  \ifnumless{\number\value{#1}}{\number\value{#2}}{%
    \hyperlink{CurrentSection::\number\value{#1}}{#3}%
    }{% Not lesser, check greater then....
    \ifnumgreater{\number\value{#1}}{\number\value{#2}}{%
      \hyperlink{CurrentSection::\number\value{#1}}{#4}%
    }{%
      % Do nothing, since both counters are equal!!!!
    }%
  }% End of \ifnumless is not true, i.e. other branch >= value of #2 
}%
}%



\makeatother

\usepackage{fancyhdr}
\fancyhf{}%
\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{.4pt}%


\fancypagestyle{contents}{%
  \lfoot{\begin{tabular}{l}%
    \CurrentSectionSymbol\textbf{\contentsname} \tabularnewline
    \tabularnewline%
    \tabularnewline%
    \tabularnewline%
\end{tabular}
}%
\cfoot{}%
\rfoot{}%
}



\fancypagestyle{normalpages}{%
  \lfoot{\begin{tabular}{l}%
    \CurrentSectionSymbol\textbf{\contentsname} \tabularnewline
    \tabularnewline%
    \tabularnewline%
    \tabularnewline%
\end{tabular}
}%
\cfoot{}%
\rfoot{}%
}


\fancypagestyle{FootLinks}{%
  \lfoot{\begin{tabular}{l}%
    \CurrentSectionSymbol\CurrentSectionName \tabularnewline
    \tabularnewline%
    \tabularnewline%
    \tabularnewline%
\end{tabular}
}%
\cfoot{\begin{tabular}{c}%
      \thepage /\pageref{LastPage}\hyperlink{page.\getpagerefnumber{anchor.lastpage}}{~\ToNextSectionSymbol}       \tabularnewline
      \tabularnewline%
      \tabularnewline%
      \tabularnewline%
\end{tabular}
}%
  \rfoot{\begin{tabular}{@{}rl}
    \hyperlink{document.toc}{\ToPreviousSectionSymbol} &     \hyperlink{document.toc}{\LinkToContentsName} \tabularnewline %
    \GenerateArrowHyperlinkToPreviousSection{CurrentSectionCounter}{NextSectionCounter}{1} & \GeneratePreviousSectionHyperlink{CurrentSectionCounter}{PreviousSectionCounter}{1} \tabularnewline%
     \GenerateArrowHyperlinkToNextSection{CurrentSectionCounter}{NextSectionCounter}{LastSectionValue} & \GenerateNextSectionHyperlink{CurrentSectionCounter}{NextSectionCounter}{LastSectionValue} \tabularnewline%
%     \DoIfIndexSection{PrintIndexSectionCounter}{CurrentSectionCounter}{\ToPreviousSectionSymbol}{\ToNextSectionSymbol} &
     \InsertToIndexSymbol{PrintIndexSectionCounter}{CurrentSectionCounter}{\ToPreviousSectionSymbol}{\ToNextSectionSymbol} &
     \hyperlink{CurrentSection::\number\value{PrintIndexSectionCounter}}{\InsertToIndexSymbol{PrintIndexSectionCounter}{CurrentSectionCounter}{\refcommand{CurrentSection::Title::\number\value{PrintIndexSectionCounter}}}{\refcommand{CurrentSection::Title::\number\value{PrintIndexSectionCounter}}}} \tabularnewline%
  \end{tabular}%
}%
\fancyhead[C]{} % Reset the header from headerref construction    
}%




\makeindex

\begin{document}
\phantomsection
\hypertarget{document.toc}{}%

\pagestyle{contents}
\tableofcontents
\clearpage

\pagestyle{normalpages}

\section{First Section}
\blindtext[2]
\index{Schr\"odinger}
\section{Another section}
\blindtext[3]

\section[Short Section Title]{Another section with a not so short title}



\section{The three witches}
\index{Shakespeare}
\index{Macbeth}


\clearpage %



\clearpage

\begin{appendices}
\clearpage
\pagestyle{FootLinks}

%\addtocontents{toc}{\protect\setcounter{tocdepth}{1}}

\section{\textbf{\textcolor{blue}{R} commando's}}

\blindtext%

\section*{And I am a completely unnumbered section and do not appear in the foot links ;-)}


\section{Begrippenlijst}
\blindtext%


\printindex% Note: \printindex behavious like an extra section

\section{\textbf{$E = mc^2$}}
\blindtext%

\section{Dummy 1}
\section{Dummy 2}
\blindtext%
\clearpage
\end{appendices}
\end{document}

enter image description here

Comments will be added soon!

Features:

  • The foot link to the next and previous secion are omitted if the standard link to index section is just one section ahead or before. The link then points to the section +- 2 ahead/before

  • \printindex behavious like a section entry now, with TOC item

  • If there is no \printindex, no bottom index link is inserted. Remove the .aux file in this case manually!
share|improve this answer
    
It is meant for sections only, not for chapters... –  Christian Hupfer May 4 at 8:49
    
Applying your \let\LaTeXStandardSection\section etc. code nested in AtBeginEnvironment{appendices} makes this functional in real documents as well (it will exclude section names of the actual document). The last hiatus will be to conditionally set the links to have the same format as what I had in my example document. –  1010011010 May 4 at 14:26
1  
@Euryis: I will look at your edits later on, what they really change. –  Christian Hupfer May 4 at 15:48
1  
@Euryris: I am working out another version of my code, which should it make easier to adapt, also providing a better counting scheme, therefore remove some errors/warnings. Basically you should get the name of the sections ahead with another counter (value) of CurrentSectionCounter + 2, but of course, you should check whether there is such a total section value at all and most probably fix the possible value at the end to the maximum section value. The same holds the other way round for sections before the current section. –  Christian Hupfer May 5 at 17:10
1  
@1010011010: I updated the code, this addresses (somehow) the other question you posted regarding the \printindex –  Christian Hupfer May 14 at 5:55

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.