1

Many text formatting commands come in two flavors: a brace-delimited version and an "declaration" version, that applies to everything after the command. For example, \textbf vs \bfseries. However, some commands do not work this way. For example, the \ul command in the soul package is only brace-delimited.

Is it possible to use this in a non-brace delimited "declaration" sort of way? If so, how would I do such a thing?

Specifically, I am using the titlesec package, and would like to underline section titles. However, the format argument for the \titleformat command seems to only accept "declaration" style commands.

How can I manage to get underlined section titles?

  • It is not clear it will give you what you want---however, the environ package allows for an environment body to be captured in a macro, \BODY, which can then be used (when properly expanded) in a braced form. – Steven B. Segletes Oct 1 '18 at 18:24
  • Also, \bf should be \bfseries. Furthermore, \bfseries (or \bf) are not environments, but declarations, that continue until explicitly turned off, or until the end of the group. – Steven B. Segletes Oct 1 '18 at 18:28
  • "...not environments, but declarations..." I will edit my question to reflect this. Thanks. Suggestions for a replacement tag for "environment" is appreciated. – Scott Oct 1 '18 at 18:32
  • 2
    In general the answer is no (the same question was asked the other day, i'll see if i can find) You can not define \bfseries in terms of \textbf , whereas \textbf can be more or less trivially defined in terms of \bfseries (\newcommand\textbf[1]{{\bfseries #1}} (the actual definition is slightly more complicated but not much. – David Carlisle Oct 1 '18 at 19:01
  • 1
3

Typographically, this is not recommended, unless you want to go back to the days of typewriters. However, here is a solution. It ises the fact that the last mandatory argument of \titleformat may end in a command with an argument which will be the section title. You may or may not want to underline the labels and section titles, or only section titles:

A solution to underline only section titles:

\documentclass[11pt, a4paper]{article}% http://ctan.org/pkg/amsproc

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{soulutf8} 

\usepackage[]{titlesec}%
\titleformat{\section}
{\Large\bfseries}
{\thesection.}
{0.33em}
{\ul}

\begin{document}

\section {The History of the Seven Families}%

           In former days – that is to say, once upon a time, there lived in the Land of Gramblamble, Seven Families. They lived by the side of the great Lake Pipple-popple (one of the Seven Families, indeed, lived in the Lake), and on the outskirts of the City of Tosh, which, excepting when it was quite dark, they could see plainly. The names of all these places you have probably heard of, and you have only not to look in your Geography books to find out all about them.

\end{document}[![enter image description here][1]][1] 

A solution to underline labels + section titles:

This code underlines labels and section titles:

\titleformat{\section}
{\Large\bfseries}
{\ul{\thesection.\enspace}}
{-0.15em}
{\ul}

enter image description here

  • "Typographically, this is not recommended"... yes, but I find that I'm rarely the master of my own typesetting requirements. :) – Scott Oct 1 '18 at 18:38
  • This only seems to underline the title, not the section number... – Scott Oct 1 '18 at 18:52
  • 1
    Yes. You didn't say clearly you wanted to underline title and label. I've posted an edit to fulfil your requirements (still not recommended, though) – Bernard Oct 1 '18 at 19:10
  • You have answered my need, and it seems as though the question as I've posed it does not have a good answer. I am going to edit the question to be such that your answer answers the question. Please feel free to propose your own edits as well. – Scott Oct 1 '18 at 19:11
  • I think it would be better, for other users, to adapt my answer to the ambiguity of your post, and propose both solutions. – Bernard Oct 1 '18 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.