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.

I've got to fix a friend's work that was done with latex. I've got almost all done, but there are a couple of issues that I couldn't fix, so I would like if you can help me please (an article document):

  • He has 4 depth sectioning in the table of contents, from part to subsubsection. The problem is that part was in roman numbering and it leaves a big heading where it's displayed. I fixed the numbering, but I can't deal with the big heading. It's displayed like:

    1
    
    Planteamiento
    
    
    1.1 Introducción
    
    (content)
    

    and it's desired something like this:

    1 Planteamiento
    
    1.1 Introducción
    
    (content)
    

    but I can't find the command to rearrange the part title. I've tried to set part as section, section as subsection, subsection as subsubsection and subsubsection to paragraph. But he also uses paragraph and I got a bit mess. So I think the easiest way is to include part as kind of "supersection". So, is there a command to fix the big part title?

  • As I've included part numbering in ToC, I had to fix section numbering to include part one. But now there is no space between the section numbers and the section name in the ToC. How can I add some space so they don't be so close?

EDIT: Here's my MWE:

\documentclass[12pt]{article}
\renewcommand{\thepart}{\arabic{part}}
\renewcommand{\thesection}{\thepart.\arabic{section}}
\renewcommand{\partname}{}

\makeatletter
\@addtoreset{section}{part}
\makeatother

\begin{document}
\tableofcontents
\newpage
\part{Big title}
\section{Lorem ipsum}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.

\section{Lorem ipsum 2}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.
\newpage
\part{Another big title}
\section{Section from big title 2}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.
\end{document}
share|improve this question
    
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  Speravir Feb 26 at 1:54
    
Edited, added my MWE. @Speravir oh, I got it now. –  Eagle Feb 26 at 2:09
1  
Hint for next time: There are (at least) three packages for dummy text: lipsum, kantlipsum and blindtext. –  Speravir Feb 26 at 2:37
    
@Speravir Ah, I was confused, I was thinking about the ToC entries and not the actual heading. I see the problem now. –  Gonzalo Medina Feb 26 at 2:48
    
@Speravir I'll delete my comments shortly. –  Gonzalo Medina Feb 26 at 3:06

1 Answer 1

up vote 5 down vote accepted

The issue with the ToC entries can be fixed using \cftsetindents from the tocloft package; the issue with the part headings can be fixed with a redefinition (or a patching) of \@part

\documentclass[12pt]{article}
\usepackage{tocloft}

\renewcommand{\thepart}{\arabic{part}}
\renewcommand{\thesection}{\thepart.\arabic{section}}
\renewcommand{\partname}{}

\makeatletter
\@addtoreset{section}{part}
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >\m@ne
       \huge\bfseries\thepart\hskip0.5em
     \fi
     \huge\bfseries #2%
     \markboth{}{}\par}%
    \nobreak
    \vskip 3ex
    \@afterheading}
\makeatother

\cftsetindents{section}{0em}{2.3em}
\cftsetindents{subsection}{2.3em}{3em}
\cftsetindents{subsubsection}{5.3em}{3.3em}

\begin{document}
\tableofcontents
\newpage
\part{Test part}
\section{Test section}
\subsection{Test subsection}
\subsubsection{Test subsubsection}

\part{Test part}
\section{Test section}
\subsection{Test subsection}
\subsubsection{Test subsubsection}

\end{document}

An image of the ToC:

enter image description here

An image of the document body:

enter image description here

Here's the code in case you opt for the patching (the code is slightly shorter):

\documentclass[12pt]{article}
\usepackage{tocloft}
\usepackage{etoolbox}

\renewcommand{\thepart}{\arabic{part}}
\renewcommand{\thesection}{\thepart.\arabic{section}}
\renewcommand{\partname}{}

\makeatletter
\@addtoreset{section}{part}
\patchcmd{\@part}{\Large}{\huge}{}{}
\patchcmd{\@part}{\partname\nobreakspace\thepart}{\thepart\hskip0.5em}{}{}
\patchcmd{\@part}{\par\nobreak}{}{}{}
\makeatother

\cftsetindents{section}{0em}{2.3em}
\cftsetindents{subsection}{2.3em}{3em}
\cftsetindents{subsubsection}{5.3em}{3.3em}

\begin{document}
\tableofcontents
\newpage
\part{Test part}
\section{Test section}
\subsection{Test subsection}
\subsubsection{Test subsubsection}

\part{Test part}
\section{Test section}
\subsection{Test subsection}
\subsubsection{Test subsubsection}

\end{document}
share|improve this answer
    
Thank you! Works like a charm! –  Eagle Feb 26 at 2:57
    
Aah, two screenshots. I was ambitious and wanted to do everything in one image. –  Speravir Feb 26 at 3:02
    
@Eagle You're welcome! Glad I could help! –  Gonzalo Medina Feb 26 at 3:04
    
@Speravir By the way, I am using your suggestion to produce the images using selectable screenshots. Works beautifully. Thnaks! –  Gonzalo Medina Feb 26 at 3:06
    
@GonzaloMedina: Great I could help. What I see now: Somewhere in Prferences there is a setting for catching the mouse cursor (don't know the English term). In most cases it’s useful to deactivate this, and only activate for the rare cases. –  Speravir Feb 26 at 3:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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