Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Possible Duplicate:
Formatting section titles

How can I change the format of section, subsection and ... to something like below?

2.1 | Greenhouse Effect

share|improve this question
    
See, for example, the answer here. With titlesec you could use something like: \titleformat{\section}{\normalfont\bf}{\thesection\hspace{5pt}$\vert$}{5pt}{} –  Scott H. Nov 30 '12 at 20:19
add comment

marked as duplicate by Scott H., Kurt, Martin Schröder, Paul Gaborit, cmhughes Nov 30 '12 at 23:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

The default formatting of section heading counters is performed by the macro \@seccntformat, which is defined in latex.ltx as

\def\@seccntformat#1{\csname the#1\endcsname\quad}

This prints the counter and inserts \quad. You can adapt this to print the counter and insert something else, like

\def\@seccntformat#1{\csname the#1\endcsname\hspace*{0.5em}$|$\hspace*{0.5em}}

This would still have a \quad-like feel, only with the insertion of a pipe:

enter image description here

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\makeatletter
% \def\@seccntformat#1{\csname the#1\endcsname\quad}% Default
\def\@seccntformat#1{\csname the#1\endcsname\hspace*{0.5em}$|$\hspace*{0.5em}}
\makeatother
\begin{document}
\section{Greenhouse effect}
\lipsum
\end{document}

Of course, this would hold far all section from the level of \section downward, whenever you have a numbered heading. Unnumbered headings will not be affected.

share|improve this answer
add comment

You can use the titlesec to help with this; I've used the lipsum package for sample text and I found \textpipe from the tipa package from The comprehensive sysmbols list.

screenshot

\documentclass{article}

\usepackage{titlesec}
\usepackage{lipsum}
\usepackage{tipa}

% custom section
\titleformat{\section}
{\normalfont\Large\bfseries}
{\thesection\hskip 9pt\textpipe\hskip 9pt}
{0pt}
{}

\begin{document}

\section{Greenhouse effect}
\lipsum[1]

\end{document}
share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.