9

The microtype protrusion won't work in my starred (unnumbered) section titles. I have a feeling that this might be part of a general bug of microtype when dealing with starting lines of environments of different kinds. So I’ve tried this: https://tex.stackexchange.com/a/13711/75284 which defines a custom protrudeleft command. Applying this to my MWE however has given me cryptic errors and no protrusion effect.

\documentclass[a5paper,10pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage[bitstream-charter]{mathdesign}
\usepackage[protrusion=true,factor=3500]{microtype}

\begin{document}
\section*{“Section* Title}
\noindent “Body Text
\end{document}

MWE

3
  • Works for \chapter* (and \chapter.
    – cfr
    Aug 24, 2015 at 22:54
  • 1
    @cfr \chapter is defined in book not article and the definition is via \secdef, rather than \@startsection for \section etc. Aug 25, 2015 at 7:24
  • @AndrewSwann Yes. I know. I just meant that it is not to do with starred divisions per se.
    – cfr
    Aug 25, 2015 at 12:11

2 Answers 2

6

I fiddled.... I have no idea what I am doing. If this breaks your document horribly, you get to keep all the itsy-bitsy pieces for yourself. I accept no responsibility if the code collaborates with your cat to order courier delivery of new tin-openers or dials out for pizza when bored.

Caveat emptor...

The basic problem, I think, is the definition of the code which initiates sections, subsections, subsubsections and paragraphs. The following code 'fixes' the issue for starred and unstarred versions of these commands.

If you customise the formatting of sections, use a non-standard class or otherwise do weird and wonderful things, this is unlikely to work. (It might. But it probably won't.)

Theoretically, it should be possible to redefine e.g. \@section... etc. directly, but the fixes do not work with, for example, titlesec.

That said:

\documentclass[a5paper,10pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage[bitstream-charter]{mathdesign}
\usepackage[protrusion=true,factor=3000]{microtype}

\makeatletter
\def\@ssect#1#2#3#4#5{% modified from latex.ltx - for starred sections below chapter level
  \@tempskipa #3\relax
  \ifdim \@tempskipa>\z@
    \begingroup
      #4{%
        \interlinepenalty \@M \noindent #5\@@par}%
    \endgroup
  \else
    \def\@svsechd{#4{%
        \cfr@microfix@sec{#1}#5}}%
  \fi
  \@xsect{#3}}
\def\@sect#1#2#3#4#5#6[#7]#8{% modified from latex.ltx - for unstarred sections below chapter level
  \ifnum #2>\c@secnumdepth
    \let\@svsec\@empty
  \else
    \refstepcounter{#1}%
    \protected@edef\@svsec{\@seccntformat{#1}\relax}%
  \fi
  \@tempskipa #5\relax
  \ifdim \@tempskipa>\z@
    \begingroup
      #6{%
        \@hangfrom{\cfr@microfix@sec{#3}\@svsec}%
          \interlinepenalty \@M #8\@@par}%
    \endgroup
    \csname #1mark\endcsname{#7}%
    \addcontentsline{toc}{#1}{%
      \ifnum #2>\c@secnumdepth \else
        \protect\numberline{\csname the#1\endcsname}%
      \fi
      #7}%
  \else
    \def\@svsechd{%
      #6{\cfr@microfix@sec{#3}%
      \@svsec #8}%
      \csname #1mark\endcsname{#7}%
      \addcontentsline{toc}{#1}{%
        \ifnum #2>\c@secnumdepth \else
          \protect\numberline{\csname the#1\endcsname}%
        \fi
        #7}}%
  \fi
  \@xsect{#5}}
\newcommand*\cfr@microfix@sec[1]{%
  \ifdim#1=0pt
    \noindent
  \else
    \hskip #1\relax
  \fi}
\makeatother

\begin{document}
\chapter{``Charlie}
\chapter*{``Charlie}
\section{Charlie nss}
\noindent {\Large\bfseries 1.1}
\section*{``Charlie ss}
\subsection{Charlie nsss}
\subsection*{``Charlie sss}
\subsubsection{``Charlie nsss}
\subsubsection*{``Charlie ssss}

\paragraph{``Charlie np} paragraph

\paragraph*{``Charlie sp} paragraph

\subparagraph{``Charlie nsp} subparagraph

\subparagraph*{``Charlie ssp} subparagraph

\noindent{\Large\bfseries``Charlie\par}
\noindent ``Charlie
\end{document}

Note that in the above code \chapter* is included for comparison because this works out-of-the-box, and this is why I switched the class to book.

Here is the result:

Charlie

Note that the above solution is general: it affects protrusion generally and not just in the case of double quotes. For example, here are some examples without my preamble modification, so that protrusion is not enabled for sectional divisions:

without protrusion

Here are the same examples with my preamble, so that protrusion is enabled:

with protrusion

Although you may be unlikely to start a section heading with ( or <, you might well begin with A or T or V or another letter for which protrusion is defined. The effect of protrusion here is more subtle, even when exaggerated as it is here, but that is the nature of micro-typography, of course: the improvements are supposed to be subtle ;).

Here is a comparison for W without the modification:

without

and with:

with

Of course, the effect is exaggerated by the protrusion factor of 3000. Here is a close up of the previous pair of images with the standard protrusion settings in place (for this font, if available). First with the standard sectioning commands:

standard sectioning

Second with the redefined versions:

redefined sectioning

So I think some general solution is required here, even if my attempt turns out to be an unsuitable one ;).

9
  • Perfect! Going the route of redefining the section* command seems to be more suited for the problem than fiddling with the character itself that needs to be protruded, as you showed for all the subtle protrusion of alphabetic characters.
    – lblb
    Aug 26, 2015 at 12:40
  • Would it be a big hassle for you to also include a redefinement of the unstarred sectioning commands? This would help if someone wants to use hanging section numbers or if a chapter/section title runs into a second line, so the missing protrusion would be noticed there.
    – lblb
    Aug 26, 2015 at 13:12
  • And another one: If I would want to customize the section title font and spacing, I see, as you predicted, that your solution doesn't work anymore. Is there a way to do these customizations without using titlesec or the like which would mess with this patch? At which places could I insert commands like \large and vspace*{-2em} in your patch code?
    – lblb
    Aug 26, 2015 at 13:38
  • 1
    @lblb About titlesec: I'm about to look into this because, now you've drawn my attention to it, the issue is bothering me in everything I write! And, although I never use it, I've just decided to try titlesec in a class wrapper I'm developing. Hopefully, I'll have an update shortly. (If not, I'll have a new question.) About the unstarred commands: there shouldn't be a problem with the second line at all. I'm not sure about the first one without testing. Have you seen an issue with these cases?
    – cfr
    Aug 26, 2015 at 17:04
  • 1
    @lblb New question...
    – cfr
    Aug 26, 2015 at 23:23
5

The inner code of \section prevents that the protrusion can work (it inserts a box with a skip and a \noindent). The \protrudeleft command from the question you linked to imho can't work here, as it implicitly assumes that it is used in vertical mode.

You can get the protrusion with the following code.

Attention

This is not a "general" code. It assumes that \textquotedblleft is defined as it is defined (and expands to the character number). I didn't test it for other encodings.

\documentclass[a5paper,10pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage[bitstream-charter]{mathdesign}
\usepackage[protrusion=true,factor=3500]{microtype}

\DeclareRobustCommand\protrudedleftquote{%
 \kern-\dimexpr\lpcode\font\textquotedblleft em/1000\relax \textquotedblleft}
 \begin{document}

\section*{“Section* Title}

\section*{\protrudedleftquote Section* Title}

“Body Text

\end{document}

enter image description here

Replacing the standard definition of “ with \DeclareUnicodeCharacter{201C}{\protrudedleftquote} as suggested by an edit is not a good idea as it will add the negative space before every quote and so break the quotes inside the running text. The command \protrudedleftquote should only be used at the begin of lines.

3
  • Thank you! To make it clear your command will use the correct microtype protrusion setting, so it's a good solution.
    – lblb
    Aug 25, 2015 at 10:04
  • @lblb: I removed your edit as the code was wrong. It will add negative spaces in places where you don't want it. Try out “Body “Text. Aug 25, 2015 at 10:39
  • @lblb Isn't the problem a more general one, though? Protrusion is not broken only for sectional headings beginning with double quote marks.
    – cfr
    Aug 25, 2015 at 21:45

You must log in to answer this question.

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