0

For my text document with the book class I start each new chapter with an abstract. The format of this abstract section is designed such that the abstract header is indented with respect to the abstract text, like:

   Abstract
Insert text here

The abstract is designed as an environment with the NewDocumentEnvironment command.

However when the titlesec package is included in the document, the indent of the abstract header is removed.

How can I keep the indent in the abstract header, or how can I tell the titlesec package to not touch the section header formatting?

The titlesec package is included because I want to customize the chapter title (and only the chapter titles).

A MWE (toggle the titlesec package to check the indentation):

\documentclass{book}
\usepackage{titlesec}
\usepackage{xparse} 
\usepackage{changepage}
\usepackage{blindtext}
\usepackage[T1]{fontenc} % Output font encoding for international characters


\NewDocumentEnvironment{ChapterAbstract}{}
    {
        % Change the margins of the abstract relative to the regular text
        \begin{adjustwidth}{15pt}{15pt} 
        \nointerlineskip\leavevmode % Necessary addition due to the macro expansion of adjustwidth. Solves the 'missing item' error
        \section*{\indent\scshape\large abstract} % Smallcaps abstract title in \large fontsize with an indentation
        \itshape
    }
    {
        \end{adjustwidth}
    }

    \begin{document}


    \chapter{Chapter title test here}
    \begin{ChapterAbstract}
    \blindtext
    \end{ChapterAbstract}

    \section{Test section}
    \blindtext
    \end{document}
3
  • Welcome to TeX SX! I have no problem with this code. Are you sure the indent disappears with just this code?
    – Bernard
    Commented Jan 8, 2019 at 18:23
  • If I toggle the titlesec package on or off, the indentation of the abstract section header changes on my pc. If it doesn't for you, I am not sure why,
    – tobyvd
    Commented Jan 8, 2019 at 19:36
  • Rien de tel chez moi.
    – Bernard
    Commented Jan 8, 2019 at 20:23

1 Answer 1

0

titlesec sets \parindent to 0pt inside the section heading, so \indent introduces an indentation of 0pt in your MWE. You can get the same effect by inserting a space of the same length manually using \hspace:

\documentclass{book}
\usepackage{titlesec}
\usepackage{xparse} 
\usepackage{changepage}
\usepackage{blindtext}
\usepackage[T1]{fontenc} % Output font encoding for international characters

\NewDocumentEnvironment{ChapterAbstract}{}
{
    % Change the margins of the abstract relative to the regular text
    \begin{adjustwidth}{15pt}{15pt} 
    \nointerlineskip\leavevmode % Necessary addition due to the macro expansion of adjustwidth. Solves the 'missing item' error
    \section*{\hspace{15pt}\scshape\large abstract} % Smallcaps abstract title in \large fontsize with an indentation
    \itshape
}
{
    \end{adjustwidth}
}

\begin{document}


\chapter{Chapter title test here}
\begin{ChapterAbstract}
\blindtext
\end{ChapterAbstract}

\section{Test section}
\blindtext
\end{document}

output

2
  • Thanks, this helped! So silly, I added \hspace{} in front of \section*{}, but that didn't work. Somehow I didn't think to try putting it inside the \section*{} command. Thanks for the quick answer.
    – tobyvd
    Commented Jan 8, 2019 at 19:41
  • @tobyvd: You're welcome. Commented Jan 8, 2019 at 19:55

You must log in to answer this question.

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