Page Layoutstartsection problems

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
eimund
Posts: 6
Joined: Mon Jul 20, 2009 1:09 pm

startsection problems

Post by eimund »

Hey,

I'm trying to create my own section and made the following code to make a subsubsubsection

Code: Select all

\makeatletter
\newcounter {subsubsubsection}[subsubsection]
\renewcommand\thesubsubsubsection{\thesubsubsection .\@arabic\c@subsubsubsection}
\newcommand{\subsubsubsection}{\@startsection{subsubsubsection}{6}{\z@}{-3.25ex\@plus -1ex \@minus -.2ex}{1.5ex \@plus .2ex}{\normalfont\normalsize\bfseries}}
\newcommand*\l@subsubsubsection{\@dottedtocline{6}{7.0em}{4.1em}}
\makeatother
The problem I have is that when I write

Code: Select all

\subsubsubsection{Hey}
then following is displayed

Code: Select all

3.1.1.1 Hey
Hey
It repeates the text. However, when I use

Code: Select all

\subsubsubsection*{Hey}
the text is written only once. Do anyone have a clue to what the problem is?

I know I can use \paragraph, but I realy want to know whats the problem and how to solve it!

Regards
Eimund

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
aphiny01
Posts: 3
Joined: Wed May 11, 2011 4:10 pm

startsection problems

Post by aphiny01 »

I have experienced the same behavior with the following code:

Code: Select all

\documentclass{article}

\newcounter{chapter}
\makeatletter
\newcommand\chapter{\@startsection{chapter}{3}{\z@}%
                                     {3.25ex\@plus 1ex \@minus .2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\large\bfseries}}
\makeatother

\begin{document}

\chapter{Test1}
\chapter*{Test2}

\end{document}
Can anyone point out what is missing?
Thanks.
aphiny01
Posts: 3
Joined: Wed May 11, 2011 4:10 pm

startsection problems

Post by aphiny01 »

I tried some additional scenarios as follows

Code: Select all

\documentclass{article}

\setcounter{secnumdepth}{-2}

\makeatletter
\newcommand\chapter{\@startsection{chapter}{3}{\z@}%
                                     {3.25ex\@plus 1ex \@minus .2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\large\bfseries}}

\renewcommand\section{\@startsection{section}{3}{\z@}%
                                     {3.25ex\@plus 1ex \@minus .2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\large\bfseries}}
\makeatother

\newcommand{\newcmd}{\large\bf}

\begin{document}

\chapter{This repeats.}
\chapter*{With Asterick, It Doesn't Repeat.}
\section{Redefining existing command does not repeat.}
\newcmd{Defining new command does not repeat.}

\end{document}
Any thoughts or help much appreciated. Thanks.
aphiny01
Posts: 3
Joined: Wed May 11, 2011 4:10 pm

startsection problems

Post by aphiny01 »

Resolved. Picked up some tidbits from an online latex guide.

Part and chapter have to defined using secdef. The following code illustrates a solution.

Code: Select all

\documentclass{article}

\makeatletter
\newcommand\chapter{
                      \secdef\@chapter\@schapter
                   }
\def\@chapter[#1]#2{
                      \normalsize \bf #2
                    }
\makeatother

\begin{document}
\chapter{This does not repeat anymore.}
\end{document}
Thanks to all.
jaykemper
Posts: 22
Joined: Wed Apr 15, 2009 12:11 am

startsection problems

Post by jaykemper »

aphiny01 wrote:Resolved. Picked up some tidbits from an online latex guide.

Part and chapter have to defined using secdef. The following code illustrates a solution.

Code: Select all

\documentclass{article}

\makeatletter
\newcommand\chapter{
                      \secdef\@chapter\@schapter
                   }
\def\@chapter[#1]#2{
                      \normalsize \bf #2
                    }
\makeatother

\begin{document}
\chapter{This does not repeat anymore.}
\end{document}
Thanks to all.

I don't think it can be classified as "resolved". It's a good way to show optional arguments (which I appreciate), but there is a lot missing from the "solution".

\refstepcounter{subsubsubsection} to step the counter?
\addtocontents{toc}{#1} to add the table of contents?
hanging numbering?
\newcommand\thesubsubsubsection{\thesubsubsection.\@arabic\c@subsubsubsection} to define the referencing?

It's just odd that you can take the same definition for the subsection, change "subsection" to "subsubsubsection" and all of a sudden it repeats.

You can use titleclass out of the titlesec package, but I've noticed that it jacks up the table of contents and I don't know how to fix it...got another thread going on that one.

So bottom line, I have no answers, just gripes. :(
jaykemper
Posts: 22
Joined: Wed Apr 15, 2009 12:11 am

startsection problems

Post by jaykemper »

eimund wrote:Hey,

I'm trying to create my own section and made the following code to make a subsubsubsection

Code: Select all

\makeatletter
\newcounter {subsubsubsection}[subsubsection]
\renewcommand\thesubsubsubsection{\thesubsubsection .\@arabic\c@subsubsubsection}
\newcommand{\subsubsubsection}{\@startsection{subsubsubsection}{6}{\z@}{-3.25ex\@plus -1ex \@minus -.2ex}{1.5ex \@plus .2ex}{\normalfont\normalsize\bfseries}}
\newcommand*\l@subsubsubsection{\@dottedtocline{6}{7.0em}{4.1em}}
\makeatother
The problem I have is that when I write

Code: Select all

\subsubsubsection{Hey}
then following is displayed

Code: Select all

3.1.1.1 Hey
Hey
It repeates the text. However, when I use

Code: Select all

\subsubsubsection*{Hey}
the text is written only once. Do anyone have a clue to what the problem is?

I know I can use \paragraph, but I realy want to know whats the problem and how to solve it!

Regards
Eimund
I think I may have the answer.

There was ONE command missing!

Code: Select all

\let\subsubsubsection\@gobble
And if you want to manipulate the format with the titlesec package

Code: Select all

\usepackage{titlesec}
...
\titleclass{\subsubsubparagraph}[\subparagraph]
rikiheck
Posts: 1
Joined: Mon Jul 10, 2023 11:29 pm

startsection problems

Post by rikiheck »

I ran into this problem as well when trying to define a special sort of section for us in postscripts to chapters. The malfunctioning code was:

Code: Select all

\newcounter{postsubsection}[postsection]
\renewcommand\thepostsubsection{\thepostsection.\arabic{postsubsection}}
\providecommand\postsubsection{\@startsection{postsubsection}{2}{\z@}%
    {-3.25ex\@plus -1ex \@minus -.2ex}%
    {1.5ex \@plus .2ex}%\@startsection
    {\normalfont\large\raggedright}}
Note that this just mimics the definition of \section in book.cls. But then I got the repeating title.

Looking at latex.ltx finally revealed that the problem was that no \postsectionmark command had been defined. So when we hit:

Code: Select all

    \csname #1mark\endcsname{#7}
in \@sect, what happens is that #7 (the optional argument, automatically generated by \@dblarg) gets printed by itself. So the solution was:

Code: Select all

\newcommand*\postsectionmark{\sectionmark}
To get these to print properly in the TOC, I also had to do:

Code: Select all

\newcommand*\l@postsection{\l@section}
But with those additions, it works perfectly.
Post Reply