0

My current problem is that while I've figured out how to control the vertical spacing around sections and subsections, in one chapter my "sections" don't really deserve the elevated formatting. What I'd like is to have LaTeX format them with section number (3.1, for example) and a bold header, and then start the paragraph on the same line, almost as though it were a glossary item. In HTML it would look like this:

<b>3.3 Profiles:</b> This worksheet contains...

I expect I should start with the titlesec package. After that...is there a way to temporarily redefine the \section layout (for this chapter only), or is there a way to relabel the sections as paragraphs (or something), or some other alternative?

5
  • 1
    are you sure that they are semantically sections? Why don't you use a list? Commented Jan 2, 2023 at 18:49
  • That is what you obtain with \setcounter{secnumdepth}{5} \paragraph{foo} bla bla ... but at the sub-sub-sub-section level. You can redefine sections to imitate the paragraph format (i.e., the sub-sub-sub-sections titles) ...but it is a good idea? A list is indeed better for me too.
    – Fran
    Commented Jan 2, 2023 at 18:54
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Jan 2, 2023 at 19:04
  • Ulrike, a list might work just fine, but I want to include the chapter number in the item—not "4 Profiles: blah blah blah" but "3.4 Profiles: blah blah blah". How would that be done? Commented Jan 2, 2023 at 19:52
  • Fran, I haven't yet used \setcounter but it says here it's for use in the preamble. As I said in my original question, I want to do this not for every part of the document but only this one chapter; I need a way to do it temporarily. But I don't mind the idea of doing a list—conceptually it makes sense—if I can number the list items with the chapter counter too. Is that possible? Commented Jan 2, 2023 at 20:00

1 Answer 1

0

The following is a list approach, using the enumerate environment that normally produces single numbers (1, 2, 3 and so on) for the main list level.

With the package enumitem the labels can be modified to include also the chapter counter. This package adds optional arguments to \begin{enumerate} for the label (many other options are added as well), i.e., \begin{enumerate}[label=xyz].

The notation \arabic* is provided to represent the current list number. The current chapter number can be printed with \thechapter (this is always available in LaTeX, also outside of enumerate environments, as well as the other counters \thesection, \thesubsection etc.).

The required format can therefore be represented as \thechapter.\arabic*. Including bold this leads to:

\begin{enumerate}[label=\textbf{\thechapter.\arabic*}]

The next step is to also include a title for each item. This is not provided by enumitem as far as I know. Therefore you need to write a small wrapper command that calls \item (which produces the numbered label) and adds the argument of the wrapper command in bold afterwards:

\newcommand{\itemtitle}[1]{%
\item \textbf{#1:}%
}

The last thing is to fix the indentation, as enumerate lists are indented by default. To remove this you can set leftmargin=* for the enumerate environment.

MWE:

\documentclass{report}
\usepackage{enumitem}

\newcommand{\itemtitle}[1]{%
\item \textbf{#1:}%
}

\begin{document}
\setcounter{chapter}{2} % skip to chapter 3
\chapter{Worksheet overview}
This chapter provides all the worksheets.
\begin{enumerate}[label=\textbf{\thechapter.\arabic*}, leftmargin=*]
\itemtitle{Preliminaries} In this worksheet the basics are discussed. There are many basics so they span over multiple lines. After this you know all the basics but you don't know what comes next.
\itemtitle{What comes next} The next steps are covered in this worksheet.
\itemtitle{Profiles} This worksheet contains profiles as well as antifiles, prefiles and postfiles.
\end{enumerate}
\end{document}

Result:

enter image description here

If you don't want the paragraphs to be indented you can also set wide=0pt instead of leftmargin=*:

enter image description here

1
  • This looks great, Marijn! I'm currently chasing another rabbit, but I've bookmarked this answer to come back to. Thanks much. Commented Jan 4, 2023 at 16:12

You must log in to answer this question.

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