Document ClassesMoving '\renewcommand' into a Class

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
isharp2
Posts: 23
Joined: Fri Feb 11, 2011 2:06 am

Moving '\renewcommand' into a Class

Post by isharp2 »

I used to have the following guidelines set up in my .tex file for customizing section, subsection and subsubsection, which redefined as 'mysection, mysubsection and mysubsubsection', respectively.

Code: Select all

%This next line makes sure to center all section titles, figures are in arabic and centered
\titleformat{\mysection}[2][]
  {\section[#1]
    {\centering #2}
%      \setcounter{figure}{0}
      \renewcommand{\thefigure}{\arabic{figure}} %Arabic figures
      \renewcommand{\thesection}{\Roman{section}}               %Roman numeral title
}

%Subsections do not get centered
\titleformat{\subsection}[2][]
{\subsection[#1]{#2}
%  \setcounter{figure}{0}
  \renewcommand{\thefigure}{\arabic{figure}}
  \renewcommand{\thesubsection}{\Alph{subsection}.} %Make sure the subsection label counter is capital A through Z followed
}

%subsub section should not include the 'ALPHA' subsection before it
\titleformat{\subsubsection}[2][]
{\subsubsection[#1]{#2}
%  \setcounter{figure}{0} %We would only reset the counter if we wanted each subsection to have a different figure number
  \renewcommand{\thefigure}{\arabic{figure}} %Set figures to Arabic numbers 1 - 9
  \renewcommand{\thesubsubsection}{\arabic{subsubsection}} %Make sure the subsection label counter is 1 through 9 with no '.', 'arabic' 
}
However, I would like to be able to move this into a class file, so that my .tex looks more clean. When I do, I get compilation errors, such as:

Code: Select all

Runaway argument?
! Paragraph ended before \ttl@format@ii was complete.
<to be read again> 
                   \par
Lastly, if there is a way to overwrite the standard article 'section', instead of redefining 'mysection', etc without losing these functions, I would be grateful to hear how.

thanks,

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply