LaTeX forum ⇒ Text FormattingCustom section headings

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
tkemeny
Posts: 2
Joined: Tue Oct 27, 2009 5:32 pm

Custom section headings

Postby tkemeny » Tue Oct 27, 2009 5:38 pm

Hi there. I'm submitting to a journal that wants me to format my sections as follows:

Sections - arabic numbered, all caps, centered
Subsections - alpha (bracketed), sentence case, centered
Subsubsections - roman (bracketed), sentence case, left aligned

I tried defining sections as follows:
  1. \def\thesection{\arabic{section}}
  2. \def\thesubsection{(\alph{subsection})}
  3. \def\thesubsubsection{(\roman{subsubsection})}


But this only gets me some of the way there. I get a period after the sub and subsubsections. For example, I get:

(a). title

instead of:

(a) title

So, first, how can I get rid of the unwanted period?

Second, how can I handle the centering without specifying it for each section?

Thanks very much.
Tom

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am
Location: Amherst, MA

Postby frabjous » Tue Oct 27, 2009 6:12 pm

You could use something like the titlesec package, e.g.:

  1. \usepackage{titlesec}
  2. \renewcommand{\thesubsection}{(\alph{subsection})}
  3. \renewcommand{\thesubsubsection}{(\roman{subsubsection})}
  4. \titleformat{\section}%
  5. {\centering\uppercase}{\thesection}{0.5em}{}
  6. \titleformat{\subsection}%
  7. {\centering}{\thesubsection}{0.5em}{}
  8. \titleformat{\subsubsection}%
  9. {\raggedright}{\thesubsubsection}{0.5em}{}


Study its manual above for more info.

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Tue Oct 27, 2009 7:26 pm

Use the titlesec package and modify the standard formats as shown in Section 9.2 (Standard Classes, p. 26f). Here is a complete example.
  1. \documentclass[11pt,a4paper,english]{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[latin1]{inputenc}
  4. \usepackage{babel}
  5. \usepackage{titlesec}
  6. \usepackage{blindtext}
  7.  
  8. \pagestyle{plain}
  9.  
  10. \titleformat{\section}{\normalfont\Large\filcenter\bfseries}{\thesection}{1em}{\uppercase}
  11. \renewcommand{\thesubsection}{\alph{subsection}}
  12. \titleformat{\subsection}{\normalfont\large\filcenter\bfseries}{(\thesubsection)}{1em}{}
  13. \renewcommand{\thesubsubsection}{\roman{subsubsection}}
  14. \titleformat{\subsubsection}{\normalfont\normalsize\bfseries}{(\thesubsubsection)}{1em}{}
  15.  
  16. \begin{document}
  17. \section{First Section}
  18. \blindtext
  19.  
  20. \subsection{First Subsection}
  21. \blindtext
  22.  
  23. \subsubsection{First Subsubsection}
  24. \blindtext
  25. \end{document}

In opposite to frabjous I used a command provided by the package to center the section headings in order to avoid possible side effects. Moreover font sizes and series remain as in the standard formats.


Best regards and welcome to the board
Thorsten¹
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses

Link:
BBcode:
HTML:
Hide post links
Show post links

tkemeny
Posts: 2
Joined: Tue Oct 27, 2009 5:32 pm

Postby tkemeny » Tue Oct 27, 2009 8:34 pm

Thank you both for your comments. Thorsten, I followed your advice and it worked perfectly. This was a big help!

Tom

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Text Formatting”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests