1

I have problem with my sectioning. I explain the problem in this code. Please run this code.

\documentclass[12pt,twoside]{book}
\usepackage{titlesec}
\titleformat*{\section}{\bf\normalsize}
\titleformat*{\subsection}{\bf\normalsize}
\titleformat*{\subsubsection}{\bf\normalsize}
\begin{document}
\chapter{Preambule}
\section{kk}
\section{kk}
\section{kk}
\section{kk}
\section{kk}
\section{kk}
\section{kk}
\section{kk}
\section{kk}
\section{kk}

Section 1.10 is not good. I want to make section Like this\\ \\
\begin{tabular}{ll}
\textbf{1.1}&\textbf{kk}\\
\textbf{1.3}&\textbf{kk}\\
\textbf{1.8}&\textbf{kk}\\
\textbf{1.10}&\textbf{kk}\\
\end{tabular}\\
but the space is not follow the 1.10, but follow the space section 1.1-1.9.
\end{document}
2
  • Can you explain clearly what is the problem you are getting?
    – tachyon
    Dec 14, 2019 at 13:54
  • @tachyon if you run the code, you will find it. I want to make the section titles look parallel from section 1.1 to 1.10. But you can see, the title of section 1.10 (section with 2 digits after the dot) looks out of alignment with section 1.1-1.9
    – Eddy
    Dec 14, 2019 at 14:18

1 Answer 1

1

You have to use titlesec advance interface and format the the section using the non-starred variant of \titleformat. Use the following command to have the labels aligned to the left:

\titleformat{\section}[hang]{\bf\normalsize}{\makebox[2em][l]{\thesection}}{1ex}{}{}

The second, optional argument to the \makebox-command is important. Standard is c, which does not look nice.

The title page you ask for, can be coded in at least two differently way. If you prefer to use \section*{section one}, the following code works:

\begin{titlepage}
\pagestyle{fancy} \section*{\fontsize{14}{12}\selectfont{\textbf{\hfill section one\hfill}}} 
\end{titlepage}

A better solution is probably to avoid the starred section command and format the title page directly:

\begin{titlepage}
 \pagestyle{fancy} 
\centering\fontsize{14}{12}\selectfont\textbf{section one} 
\end{titlepage}

Here is the code for your original question.

enter image description here

\documentclass[12pt,twoside]{book}
\usepackage{titlesec}
\titleformat{\section}[hang]{\bf\normalsize}{\makebox[2em][l]{\thesection}}{1ex}{}{}
\titleformat*{\subsection}{\bf\normalsize}
\titleformat*{\subsubsection}{\bf\normalsize}
\titlelabel{hlabel-formati}

\begin{document}
\chapter{Preambule}
\section{kk}
\section{kk}
\section{kk}
\section{kk}
\section{kk}
\section{kk}
\section{kk}
\section{kk}
\section{kk}
\section{kk}

Section 1.10 is not good. I want to make section Like this\\ \\
\begin{tabular}{ll}
\textbf{1.1}&\textbf{kk}\\
\textbf{1.3}&\textbf{kk}\\
\textbf{1.8}&\textbf{kk}\\
\textbf{1.10}&\textbf{kk}\\
\end{tabular}\\
but the space is not follow the 1.10, but follow the space section 1.1-1.9.
\end{document}
2
  • thank you. it's work, but in another case, this code make make '\begin{titlepage} \pagestyle{fancy} \section*{\centering\fontsize{14}{12}\selectfont{\textbf{section one}}} \end{titlepage}' is not center. how to fix it?
    – Eddy
    Dec 15, 2019 at 4:34
  • thank you. It's work
    – Eddy
    Dec 15, 2019 at 14:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .