5

I'm writing a prospectus and my college has given me the following class for formatting it. I'm new to Latex and I've seen the these examples already (one, two, and three) but I can't understand how to apply them to the class I have. Here is (I believe) the relevant pieces of the class.

% -- Section Headings --  modified revtex4.sty
\renewcommand{\thesection}{\Roman{section}.}
\renewcommand{\thesubsection}{\Alph{subsection}.}
\renewcommand{\thesubsubsection}{\arabic{subsubsection}.}

\renewcommand{\section}{\@startsection
{section}%                          % the name
{1}%                                % the level
{\z@}%  %\z@ = 0pt.                 % the indent
{.8cm \@plus1ex \@minus .2ex}%      % the beforeskip
{.25cm}%                            % the afterskip
{\normalfont\large\sffamily\bfseries}}%      % the style

\renewcommand{\subsection}{\@startsection
{subsection}%
{2}%
{1ex}%
{.8cm \@plus1ex \@minus .2ex}%
{.125cm}%
{\normalfont\normalsize\bfseries}}%

\renewcommand{\subsubsection}{\@startsection
{subsubsection}%
{3}%
{1.25ex}%
{.5cm \@plus1ex \@minus .2ex}%
{.125cm}%
{\normalfont\normalsize\itshape}}%

With the class as currently show when I enter:

\section{Example}\label{example}
Section \ref{example} is my example section.

I get something like:

I.Example

Section I. is my example section.

I'm trying to remove the trailing period in the text but not in the section heading itself. If anyone can help me fix this I'd be grateful!

2
  • The trailing period is introduced right at the beginning with \renewcommand{\thesection}{\Roman{section}.} If you alter that definition, it will go, although it will remove the period in the headings as well, so you will have to make other changes to put it back. Imvho those changes at the start weren't the best approach. It's a little bit difficult to completely answer this question, I think, without knowing precisely what you want.
    – Au101
    Jul 27, 2015 at 23:50
  • Welcome! Code fragments are of limited usefulness. A complete example and, if necessary, a link to the class would be helpful. The code posted can be adapted to remove the dot. But I don't think it can be adapted to include it in the title of the section. We need another bit for that.
    – cfr
    Jul 27, 2015 at 23:50

2 Answers 2

8

The ending-period stems from the fact that you're including it in the counter representations

\renewcommand{\thesection}{\Roman{section}.}
\renewcommand{\thesubsection}{\Alph{subsection}.}
\renewcommand{\thesubsubsection}{\arabic{subsubsection}.}

since \thesection (and friends) are used as-is for writing the references when using \label. Instead, you should change \@seccntformat for adding an ending-period in all sectional headings:

\makeatletter
\renewcommand\@seccntformat[1]{\csname the#1\endcsname.\quad}
\makeatother

The above definitions of \the... still seems strange as they are not hierarchical. Typically \thesubsubsection would include a reference to \thesubsection, and similarly \thesubsection would include a reference to \thesection. My suggestion would therefore be to use

\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\thesubsection}{\thesection.\Alph{subsection}}
\renewcommand{\thesubsubsection}{\thesubsection.\arabic{subsubsection}}

However, the choice is eventually yours.

1
  • This solution worked for me, however this was inside a .cls file so I left off the \makeatletter and \makeatother commands. I also had to remove the period after all the counter representations. As for prepending the section onto the subsection, etc. That would be against the department's style guide for this particular doc unfortunately since that would be clearer. Jul 28, 2015 at 17:52
2

It is quite easy to do with titlesec:

\renewcommand{thesection}{\Roman{section}}

\titleformat{\section}{\normalfont\large\sffamily\bfseries}%global formatting (label %and title}%
{\thesection.}%label formatting
{0.5em}% separation between label and title
{}%commands to be  applied to the title
[]% optional argument after title

\titlespacing{0pt}{.8cm \plus1ex \minus .2ex}{0.25cm}
1
  • I think that, in the question, revtex4.sty should probably be revtex4.cls since the former appears to have the disadvantage of not existing. If so, won't this fail with compilation errors? I tried it with the unmodified revtex4 class and got complaints about inaccessible things immediately. Admittedly, without the actual class file, it is impossible to know it won't work since they might have modified it to be titlesec-friendly, but on the balance of probabilities....
    – cfr
    Jul 28, 2015 at 1:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .