Text Formatting\section formating question

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
huuep
Posts: 5
Joined: Wed Aug 05, 2009 2:30 pm

\section formating question

Post by huuep »

how do i use \section{} so that i can put the number in the middle, have an output like this:

Article 1 - Stuff

where the 1 is auto-numbered, instead of

1 Article - Stuff

if i do \section{Article - Stuff}

thanks!
danny

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
huuep
Posts: 5
Joined: Wed Aug 05, 2009 2:30 pm

\section formating question

Post by huuep »

perhaps this question is more clear.

Code: Select all

 
/section{article - first}
/section{article - second}
/section{article - third}
will output:
1 article - first
2 article -second
3 article - third

how do i write it so that i get:
article 1 - first
article 2 - second
article 3 - third

thanks!
danny
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

\section formating question

Post by gmedina »

Hi,

your example suggest that the word "article" will be constant in the title, so to achieve something like

Code: Select all

article 1 - first
article 2 - second
article 3 - third
you need only to make some changes to the sections format (with the help of the titlesec package) and then simply use

Code: Select all

\section{first}
\section{second}
\section{third}
in your document. The following simple example illustrates this approach:

Code: Select all

\documentclass{article}
\usepackage{titlesec}

\titleformat{\section}
  {\normalfont\Large\bfseries}{article\space\thesection\space--\space}{0pt}{}
\titlespacing*{\section}
  {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

\begin{document}

\section{first}

\section{second}

\section{third}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
huuep
Posts: 5
Joined: Wed Aug 05, 2009 2:30 pm

Re: \section formating question

Post by huuep »

awesome, thanks very much!
-danny
Post Reply