[texhax] \subsubsection*{}

Philip G. Ratcliffe philip.ratcliffe at fastwebnet.it
Mon Jan 7 23:03:53 CET 2008


> I redefined \subsubsection so as not to put the header on a 
> separate line. 
> Inevitably some author decided to use \subsubsection*{} (for no 
> discernable reason;  why not use \par\kern5pt\noindent?)  

Better still might be something like \\[\parskip]

> This results in 
> an unwanted space, which you will see if you compose this:
> [snip]

Hmm, this does look like an oversight in the basic LaTeX file and I would
expect that someone else already has a solution (the same problem arises for
any sectioning command that does not provide a number (as in the use of
\paragraph below without my hack).  The problem seems to be the space
inserted between the chapter/section number and the title even when the
latter is absent.

So here's my hack (the insertions are clearly marked):

\documentclass{article}
\makeatletter
%
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                      {-3.25ex\@plus -1ex \@minus -.2ex}%
                                      {-1.5ex \@plus -.2ex}%
                                      {\normalfont\normalsize\bfseries}}
%
\def\@sect#1#2#3#4#5#6[#7]#8{%
  \ifnum #2>\c at secnumdepth
    \let\@svsec\@empty
  \else
    \refstepcounter{#1}%
    \protected at edef\@svsec{\@seccntformat{#1}\relax}%
  \fi
  \@tempskipa #5\relax
  \ifdim \@tempskipa>\z@
    \begingroup
      #6{%
        \@hangfrom{\hskip #3\relax\@svsec}%
          \interlinepenalty \@M #8\@@par}%
    \endgroup
    \csname #1mark\endcsname{#7}%
    \addcontentsline{toc}{#1}{%
      \ifnum #2>\c at secnumdepth \else
        \protect\numberline{\csname the#1\endcsname}%
      \fi
      #7}%
  \else
    \@setsectspace{#8}% <== ADDITION
    \def\@svsechd{%
      #6{\hskip #3\relax
      \@svsec #8}%
      \csname #1mark\endcsname{#7}%
      \addcontentsline{toc}{#1}{%
        \ifnum #2>\c at secnumdepth \else
          \protect\numberline{\csname the#1\endcsname}%
        \fi
        #7}}%
  \fi
  \@xsect{#5}}
%
\def\@ssect#1#2#3#4#5{%
  \@tempskipa #3\relax
  \ifdim \@tempskipa>\z@
    \begingroup
      #4{%
        \@hangfrom{\hskip #1}%
          \interlinepenalty \@M #5\@@par}%
    \endgroup
  \else
    \@setsectspace{#5}% <== ADDITION
    \def\@svsechd{#4{\hskip #1\relax #5}}%
  \fi
  \@xsect{#3}}
% == BEGIN ADDITION
\newif\if at sectspace \@sectspacetrue
%
\def\@setsectspace#1{%
  \def\reserved at a{#1}%
  \ifx\reserved at a\@empty\@sectspacefalse\else\@sectspacetrue\fi
}
% == END ADDITION
\def\@xsect#1{%
  \@tempskipa #1\relax
  \ifdim \@tempskipa>\z@
    \par \nobreak
    \vskip \@tempskipa
    \@afterheading
  \else
    \@nobreakfalse
    \global\@noskipsectrue
    \everypar{%
      \if at noskipsec
        \global\@noskipsecfalse
       {\setbox\z@\lastbox}%
        \clubpenalty\@M
        \begingroup \@svsechd \endgroup
        \unskip
      \if at sectspace% <== ADDITION
        \@tempskipa #1\relax
        \hskip -\@tempskipa
      \fi% <== ADDITION
      \else
        \clubpenalty \@clubpenalty
        \everypar{}%
      \fi}%
  \fi
  \ignorespaces}
%
\makeatother
\begin{document}

\paragraph{}This is a test.  This is a test.  This is a test. This is a
test.  This is a test.  This is a test.  This is a test.  This is a test.
This is a test.  This is a test.

\paragraph{Test}This is a test.  This is a test.  This is a test. This is a
test.  This is a test.  This is a test.  This is a test.  This is a test.
This is a test.  This is a test.

\subsubsection{}This is a test.  This is a test.  This is a test. This is a
test.  This is a test.  This is a test.  This is a test.  This is a test.
This is a test.  This is a test.

\subsubsection{Test}This is a test.  This is a test.  This is a test. This
is a test.  This is a test.  This is a test.  This is a test.  This is a
test.  This is a test.  This is a test.

\subsubsection*{}This is a test.  This is a test.  This is a test. This is a
test.  This is a test.  This is a test.  This is a test.  This is a test.
This is a test.  This is a test.

\subsubsection*{Test}This is a test.  This is a test.  This is a test. This
is a test.  This is a test.  This is a test.  This is a test.  This is a
test.  This is a test.  This is a test.

\end{document}

Cheers,  Phil



More information about the texhax mailing list