1

I am trying to achieve the following formatting using the titlesec package.

desired format

\titleformat{}[wrap]{}{}{}{} works well to achieve the "5.2." and the wrapping of its child text.

What is the best way to achieve the next layer of formatting, for the alphabetically ordered text? That is, instead of wrapping, I would like the child text (the latin script) to be formatted as an aligned (indented) block. Note additionally, I would like to be able to provide un-indented 'answer contents' for each alphabetically ordered layer.

I am wondering if there is an 'industry-standard' solution to this particular formatting schema in LaTeX!

Here is a failed implementation:

\documentclass{article}
\usepackage{titlesec} % section headings
\setcounter{secnumdepth}{0}
\titleformat{\section}[wrap]{\normalfont}{}{}{}
\titleformat{\subsection}[block]{\normalfont}{}{}{} % block --> ??

\begin{document}

\section{5.2.}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget vestibulum dolor. Donec commodo nec lorem quis faucibus. Sed ligula metus, aliquet vel turpis vel, maximus dictum tellus. Ut ullamcorper neque nisi, dictum rutrum turpis tincidunt non. Curabitur sagittis, nulla nec aliquam tristique, diam turpis venenatis quam, quis suscipit tellus mi et sapien. Quisque diam justo, pharetra rhoncus risus eget, aliquet hendrerit nisi.

\subsection{a.}

{Aliquam a mauris lacus. Nulla at tempus leo. Nullam convallis odio turpis, a mattis est venenatis non. Cras ut viverra nisl. Vestibulum mollis sapien justo, eget fermentum tellus gravida in. Proin sed risus nec ipsum rutrum rutrum ac quis eros.}

Answer content (a)

\end{document}

Which renders as:

render

Clearly it is lacking both the desired formatting for (a), as well as the ability to have un-indented answer content.

NOTE: This was answered in a better question, considering all answers to this one pointed me towards a different solution entirely (particularly, I ended up using enumitem rather than titlesec, dropping the \subsection formatting I was using for the a., b., c., etc).

shea
  • 63
  • welcome to tex.sx. This question would benefit from the addition of a small compilable example, beginning with \documentclass and ending with \end{document}. Without knowing the document class and other relevant packages that you are using, any attempt at an answer would be largely a guess. – barbara beeton Dec 12 '23 at 15:34
  • thanks, updated with example – shea Dec 13 '23 at 02:00
  • How is TeX to know when subsection a has "ended" and "Answer content (a)" has started? The latter has a different indent. I don't think you really want to use subsection for the alphabetic items. You probably want some sort of environment. – Willie Wong Dec 13 '23 at 09:01

1 Answers1

1

This is more readily achievable using lists.

enter image description here

\documentclass{article}

\usepackage{enumitem}

\begin{document}

\begin{enumerate}[itemindent=1em,labelwidth=3em,align=left] \item[5.2.] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget vestibulum dolor. Donec commodo nec lorem quis faucibus. Sed ligula metus, aliquet vel turpis vel, maximus dictum tellus. Ut ullamcorper neque nisi, dictum rutrum turpis tincidunt non. Curabitur sagittis, nulla nec aliquam tristique, diam turpis venenatis quam, quis suscipit tellus mi et sapien. Quisque diam justo, pharetra rhoncus risus eget, aliquet hendrerit nisi.

\begin{enumerate} \item[a.] Aliquam a mauris lacus. Nulla at tempus leo. Nullam convallis odio turpis, a mattis est venenatis non. Cras ut viverra nisl. Vestibulum mollis sapien justo, eget fermentum tellus gravida in. Proin sed risus nec ipsum rutrum rutrum ac quis eros. \end{enumerate}

Answer content (a)

\begin{enumerate} \item[b.] Aliquam a mauris lacus. Nulla at tempus leo. Nullam convallis odio turpis, a mattis est venenatis non. Cras ut viverra nisl. Vestibulum mollis sapien justo, eget fermentum tellus gravida in. Proin sed risus nec ipsum rutrum rutrum ac quis eros. \end{enumerate}

Answer content (b) \end{enumerate}

\end{document}

With a more clear context, some automation can be incorporated (using series to define a specific list style/format, for example).

Werner
  • 603,163
  • only difference in my solution was i kept the \section formatting for 5.2., and specified my enumerate environment with [label={\alph*.}] while using [resume*] to keep it consistent across environments. – shea Dec 15 '23 at 05:58