1

I'm writing a document (article class). I'm using the clever reference package to crossreference sections, and I have modified the references so the \cref{label} produces, for example if it's section 2, the symbol §2. I have also modified the (sub)section and part title formats via titlesec, all with the following code:

\crefname{section}{§}{§§}
\Crefname{section}{§}{§§}
\crefname{part}{§}{§§}
\titleformat*{\section}{\Large §\scshape\centering}
\titleformat*{\subsection}{\large §\scshape}
\titleformat{\part}[display]
   {\LARGE §\scshape\centering}
   {\thepart}
   {0em}
   {}

The last thing I would like to do is to make it print the symbol § before the number of the section in each section. I have tried doing like above, just putting it in the second {} of the titleformat command for each of them, but that obviously writes it before the title of the section, leaving something like this:

3.1 §This is a section.

Plus Auctex returns an error when compiling with Latex (Error ocurred after las TeX file closed) although it produces the correct dvi file.

How could I correctly achieve that?

Thanks in advance.

Johannes_B
  • 24,235
  • 10
  • 93
  • 248
MyUserIsThis
  • 1,201
  • 2
    Please give a compilable MWE which shows your documentclass and a sample section. Thanks. – LaRiFaRi Apr 28 '15 at 08:07
  • 1
    Please post a compilable MWE, not just code snippets. It's unproductive having to guess, for instance, which package needs to be loaded in order to enable the macro \titleformat. – Mico Apr 28 '15 at 08:08
  • Related: http://tex.stackexchange.com/q/127623 and http://tex.stackexchange.com/q/14623 – LaRiFaRi Apr 28 '15 at 08:09
  • The usage of the paragraph sign hints that your document might have a legal background. There are some packages for legal documents, so if you tell us, what kind of document it is and in which level of sections you'd like to have a §. – Keks Dose Apr 28 '15 at 08:10
  • @KeksDose Nope, it's a mathematical document. Just sections and subsections. – MyUserIsThis Apr 28 '15 at 08:13

1 Answers1

3

Ok, solved it, didn't know how to use properly the \titlesec command. I used

\titleformat{\section}[hang]{\Large\scshape\centering}{§\thesection}{1em}{}
\titleformat{\subsection}[hang]{\large\scshape}{§\thesubsection}{1em}{}

Without the * for full formatting.

Sorry for asking and answering myself.

EDIT: Just for future reference, in case someone runs into this: In the previous snippet, the four {} parts at the right of the [] are: text-style, then what's displayed before the (sub)section title, then the space between enumeration and title, and then something to separate enumeration and title. In this case \thesection outputs the number of the section, 1em is the space between the number of the section and the title, and there's symbolic separation between them.

The [] can be hang in which case al of it is displayed in a single line, or display, in which case there is a line for the enumeration, then a line with the separation (fourth {}), and then the title.

MyUserIsThis
  • 1,201
  • 1
    Well, then accept your own answer to avoid that this question will be regarded as unanswered by the system. – Keks Dose Apr 28 '15 at 08:30
  • You can answer your own questions, but I think the system will prevent you from accepting your own answer for a while (to give others the chance to respond as well). But yes, the system allows you to answer your own questions, no need to apologise. – Alenanno Apr 28 '15 at 09:01
  • @KeksDose It doesn't allow me to do so until 2 days have passed... – MyUserIsThis Apr 28 '15 at 15:17