I want to create a macro which will reference a given section (or chapter, part, subsection, etc.) but if the section referenced is the next section after the current one, it will say "the next section" rather than "Section X", and the same for the previous section and "the previous section". What I'm imagining the pseudocode would look like is something like this:
\usepackage{\ifthen}
\newcommand{\secref}[1]{
\ifthenelse{\equal{\thesection}{\ref{#1}-1}}
{the next section}
{\ifthenelse{\equal{\thesection}{\ref{#1}+1}}
{the previous section}
{Section #1}}}
Is there a package for this? And if not, how would I go about creating a solution?
\section
,\subsection
,\subsubsection
is LaTeX terminology for distinguishing the depth of numbering of -well- section-headings. Outside LaTeX terminology there is more than one "sectioning doctrine". In many "sectioning doctrines", e.g., section 1.7 does not contain subsection 1.7.1 but section 1.7 ends and section 1.7.1 begins. With such doctrines a section 1.7 is the previous section of section 1.7.1, while section 1.7.1 is the previous section of section 1.7.2, which in turn is the previous section of section 1.7.2.1 which in turn might be the previous section of section 1.8.