1

As the title states, I wish to skip sections, specifically every other section. The manual and probably easiest way to do so is to use

\setcounter{section}{#}
\addtocounter{section}{1}
\section

That would allow me to get all the even/odd sections, etc. However, I would have to manually add an increment each time. Is there an automated process to do so? As in, change the counter of sections so that it increments by 2 every time instead of 1?

  • What \documentclass are you using? Do you want that for sections only or for chapters and sub(sub)sections? – Phelype Oleinik Jun 3 at 9:22
2

One way is to make the print format of the counter twice the underlying value.

enter image description here

\documentclass{article}

\renewcommand\thesection{\the\numexpr2*\value{section}-1\relax}
\begin{document}

\section{zzz}
z
\section{zzzz}
z
\section{zzzz}
z

\end{document}
0

Here is a way by "redefining" section (To be clear didn't redefined that, but you can do it by changing just the definition \def\msection to \def\section)...

Everything is working as expected...

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{fancyhdr}
\let\oldsection\section
\makeatletter
\def\msection{%
\@ifstar{\@Starred}{\@nonStarred}%
}
\def\@Starred{%
\@ifnextchar[%
{\GenericWarning{}{Warning: A starred section can not have optional parameters. I am going to ignore them!}\@StarredWith}%
{\@StarredWithout}%
}      
\def\@StarredWith[#1]#2{%
\oldsection*{#2}%
}
\def\@StarredWithout#1{
\oldsection*{#1}%
}
\def\@nonStarred{%
\@ifnextchar[%
{\@nonStarredWith}%
{\@nonStarredWithout}%
}
\def\@nonStarredWith[#1]#2{%
\addtocounter{section}{1}
\oldsection[#1]{#2}%
}
\def\@nonStarredWithout#1{%
\addtocounter{section}{1}
\oldsection{#1}%
}
\makeatother 

\begin{document}
\pagestyle{fancy}

\msection{Introduction}

\msection{First}

\msection{Second}

\msection*{Third}
\lipsum


\msection[Fourth]{long Forth}

\end{document}

Sorry (no screenshot on my pc right now ... I could add later one)

PS: From this old answer of mine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.