TeX - LaTeX Asked by Kait on March 19, 2021
So basically I need to have two different section headings; one that is alphanumeric (A, B, C…) and one that is labelled like Experiment #1, Experiment #2, etc.
So far I found this solution that was helpful for the alpha sections. https://stackoverflow.com/questions/2839647/latex-how-to-change-one-of-section-numbers-to-a-custom-letter
This is what I’ve tried:
documentclass[titlepage]{report}
newcounter{alphasect}
defalphainsection{0}
newififalphainsection
letoldsection=section
defsection{%
ifalphainsection
addtocounter{alphasect}{1}
fi%
oldsection}%
renewcommandthesection{%
ifalphainsection%
Alph{alphasect}
else%
arabic{section}
fi%
}%
newenvironment{alphasection}{%
ifalphainsection%
errhelp={Let other blocks end at the beginning of the next block.}
errmessage{Nested Alpha section not allowed}
fi%
setcounter{alphasect}{0}
alphainsectiontrue
}{%
setcounter{alphasect}{0}
alphainsectionfalse
}%
%https://stackoverflow.com/questions/2839647/latex-how-to-change-one-of-section-numbers-to-a-custom-letter
%This is for Experiment Sections to be numbered as "EXPERIMENT #__"
newcommand{experimentarabic}{EXPERIMENT #arabic}
newcounter{expsect}
defexpinsection{0}
newififexpinsection
letoldsection=section
defsection{%
ifexpinsection%
addtocounter{expsect}{1}
fi%
oldsection}%
renewcommandthesection{%
ifexpinsection%
experimentarabic{expsect}
else%
arabic{section}
fi%
}%
newenvironment{expsection}{%
ifexpinsection%
errhelp={Let other blocks end at the beginning of the next block.}
errmessage{Nested exp section not allowed}
fi%
setcounter{expsect}{0}
expinsectiontrue
}{%
setcounter{expsect}{0}
expinsectionfalse
}%
begin{document}
title{Title}
author{Author}
date{Date}
maketitle
tableofcontents
begin{alphasection}
section{First alpha section}
section{Second alpha section}
section{Third alpha section}
end{alphasection}
setcounter{section}{0}
begin{expsection}
section{First Experiment section}
section{Second Experiment section}
section{Third Experiment section}
end{expsection}
end{document}
I basically just tried to do the same thing to set up a new environment and then I can reset the section counter when starting my Experiment #_ sections.
This code doesn’t work though, and it was important for me to have the sections not just be section*(Experiment #1...)
because I need them to show up in the ToC, and not setcounter{secnumdepth}{0}
because I need figures and equations to be like "Figure 1.1" for Experiment #1.
Hopefully somebody sees my error or has any better ideas to get this. Thanks!
EDIT: For some reason both the alphasection and expsection work when I comment the other out. They don’t work together for some reason. Also the ToC for the Experiment #_ sections are super squished.
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP