# Different spacing between title, subtitle and text, and subsection text alignment

1. Is there any way to make first line of subsection title be aligned with \parident and second line -- aligned to the left?

1. I need to make different spacing between title, subtitle and subsubtitle: a. Spacing between section title and subsection title -- 8mm; b. Spacing between any title and text -- 15mm; c. Spacing between text and subsection title --- 1,5 linespacing.

Tried to do this way, but it doesn't give right results:

\documentclass{article}

\usepackage{titlesec}
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,russian]{babel}

\titleformat{\section}{\normalfont\fontsize{16}{15}\bfseries\filcenter}{\thesection}{1em}{}
\titleformat{\subsection}{\normalfont\fontsize{14}{15}\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}{\normalfont\fontsize{14}{15}}{\thesubsubsection}{1em}{}

\titlespacing{\section}{}{10mm}{10mm}
\titlespacing{\subsection}{\parindent}{25mm}{15mm}
\titlespacing{\subsubsection}{\parindent}{25mm}{15mm}

\begin{document}

\section{For three years, car mechanic Paen Long stayed up long after his wife went to bed each night, spending countless hours watching videos on YouTube}

\subsection{For three years, car mechanic Paen Long stayed up long after his wife went to bed each night, spending countless hours watching videos on YouTube}

\subsubsection{For three years, car mechanic Paen Long stayed up long after his wife went to bed each night, spending countless hours watching videos on YouTube}

For three years, car mechanic Paen Long stayed up long after his wife went to bed each night, spending countless hours watching videos on YouTube.

\end{document}


UPD. After system upgrade (including texlive upgrade) there is no text in titles if I use \titleformat.

• \titleformat{\subsection}[block]{\normalfont\fontsize{14}{15‌​}\bfseries}{\thesubs‌​ection}{1em}{} does the job for the first point. For the second (which is not very clear, I confess) try to with the option [largestsep]/[aftersep] (the latter is the default). – Bernard Jun 3 '17 at 20:20
• @Moriambar: Done, mylord. – Bernard Jun 3 '17 at 20:21
• Is the cyrillic script relevant to the question? If not, please replace it with some text using the latin alphabet. More people will have a look and the answer will help more people as well. – Johannes_B Jun 4 '17 at 7:39
• @Bernard, solutions works with 1st point! – Frigate Jun 4 '17 at 12:30
• @Johannes_B, I've edited post. – Frigate Jun 4 '17 at 12:32

The problem of spacing between section and subsection can't have an automatic solution, insofar as you can't know in advance whether the section title is followed by some text, or a subsection title. So I think you'll have to do it by hand.

The following code is a solution to what I've understood of your requirements:

\documentclass{article}
\usepackage[T1]{fontenc}%,T2A
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}%,russian
\usepackage{fourier, erewhon}

\usepackage[aftersep]{titlesec}
\titleformat{\section}{\normalfont\fontsize{16}{15}\bfseries\filcenter}{\thesection}{1em}{}
\titleformat{\subsection}[block]{\normalfont\fontsize{14}{15}\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}[block]{\normalfont\fontsize{14}{15}}{\thesubsubsection}{1em}{}

\titlespacing{\section}{0pt}{10mm}{10mm}
\titlespacing{\subsection}{0pt}{25mm}{15mm}
\titlespacing{\subsubsection}{0pt}{25mm}{0.5\baselineskip}

\begin{document}

\section{For three years, car mechanic Paen Long stayed up long after his wife went to bed each night, spending countless hours watching videos on YouTube}\vspace{-4ex}

\subsection{For three years, car mechanic Paen Long stayed up long after his wife went to bed each night, spending countless hours watching videos on YouTube}

\subsubsection{For three years, car mechanic Paen Long stayed up long after his wife went to bed each night, spending countless hours watching videos on YouTube}

For three years, car mechanic Paen Long stayed up long after his wife went to bed each night, spending countless hours watching videos on YouTube.

\end{document}


• Thanx! It works for me, but only in MWE. In my document where knitr is used \vspace does nothing. – Frigate Jun 4 '17 at 15:27
• I don't know knitr, so I can't help unfortunately. Just in case, try \vspace* or \leavevmode\vspace. – Bernard Jun 4 '17 at 15:51
• Sorry, everything works clear, it was just my stupid mistake. Big thanks again! – Frigate Jun 4 '17 at 16:43