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?

Rex Lam
  • 45

2 Answers2

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}
David Carlisle
  • 757,742
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.

koleygr
  • 20,105