Page LayoutNeed help Removing "Part" from the \part{stuff} headings

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
rockrat0
Posts: 4
Joined: Sun Jan 04, 2009 9:06 am

Need help Removing "Part" from the \part{stuff} headings

Post by rockrat0 »

I am using revtex4, which has an inherent documentclass of "article" and therefore I can't use the \Chapter headings. I have partially worked around this by using:

\renewcommand\thepart{Chapter \arabic{part}}
\renewcommand\thesection{\arabic{part}.\arabic{section}}

This gets the part numbers to function as effective chapter numbers for TOC and such.
The problem is when using the "Part" section heading
\part{Chapter title}
it renders in the text as:

Part Chapter X
Chapter title

On two lines
I would like this to actually render as:

Chapter X Chapter title

on one line, but two would be okay. Mostly I need to know how to make latex remove the word "Part"!!!, and to just print the number.
This may be a very simple fix, but I'm having trouble finding out how to do it. I would prefer to not have to build a new counter command, if possible. Any help would be appreciated.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Need help Removing "Part" from the \part{stuff} headings

Post by gmedina »

Hi,

one possible solution is to redefine the \part command as implemented by revtex4. Take a look at the following simple example code:

Code: Select all

\documentclass{revtex4}

\makeatletter
\def\part{\par
   \addvspace{4ex}%
   \@afterindentfalse
   \secdef\@part\@spart}%
\def\@part[#1]#2{%
 \@ifnum{\c@secnumdepth >\m@ne}{%
        \refstepcounter{part}%
        \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
 }{%
      \addcontentsline{toc}{part}{#1}%
 }%
 \begingroup
    \parindent \z@ \raggedright
    \interlinepenalty\@M
    \@ifnum{\c@secnumdepth >\m@ne}{%
      \Large \bf Chapter~\thepart\enspace%
    }{}%
    \huge \bf
    #2%
    \markboth{}{}\par
 \endgroup
   \nobreak
   \vskip 3ex
   \@afterheading
}%
\makeatother

\begin{document}

\part{Some title}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
rockrat0
Posts: 4
Joined: Sun Jan 04, 2009 9:06 am

Need help Removing "Part" from the \part{stuff} headings

Post by rockrat0 »

Thanks for the help, that does work! I still am having trouble getting the page numbers of the "part" to show up in the table of contents, but I will make a new post to that effect.

I did come to the following, slightly different answer once I started playing around with the revtex4.cls (which I wouldn't have even attempted to mess with until you posted):

Changes I made in revtex4.cls:

Code: Select all


%%line 5885
\def\partname{Chapter} %%old code was: \def\partname{Part} % this acheives the original request of replacing "Part" with "Chapter"

%%line 5106
\def\thepart     {\arabic{part}} %old code:\def\thepart     {\Roman{part}} %this makes part numbers always arabic instead of Roman

%%starting at line 5134
\def\part{\par
   \addvspace{4ex}%
   \@afterindentfalse
   \secdef\@part\@spart}%
\def\@part[#1]#2{%
 \@ifnum{\c@secnumdepth >\m@ne}{%
        \refstepcounter{part}%
        \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
 }{%
      \addcontentsline{toc}{part}{#1}%
 }%
 \begingroup
    \parindent \z@ \center %%old code was \raggedright % this centers the part number and part title
    \interlinepenalty\@M
    \@ifnum{\c@secnumdepth >\m@ne}{%
      \Large \bf \partname~\thepart%
      \par\nobreak
    }{}%
    \Large \bf %%old code was \huge \bf % this makes the part number and the parttitle the same font size
    #2%
    \markboth{}{}\par
 \endgroup
   \nobreak
   \vskip 3ex
   \@afterheading
}%
\def\@spart#1{{\parindent \z@ \raggedright
    \interlinepenalty\@M
    \Large \bf %% old code was: \huge \bf %this is for consistency of font size with counted and non-counted part headings.
    #1\par}
    \nobreak
    \vskip 3ex
    \@afterheading}
    
Note that this prints:
\part{Chapter title}
as:
Chapter <arabic number>
Chapter title

The suggestion by gmedina also works fine, and, as written, prints:
\part{Chapter title}
as:
Chapter <roman numeral> Chapter title

My code fixes I think will only work if you do them within the revtex4.cls file, while gmedina's seem to work by plopping them in your .tex file.
Post Reply