22

When the microtype package is loaded a quote environment which starts with punctuation marks is inconsistent "indented". The first line in the following minimal example is unaffected, i.e. at the same place as without the package, but the next two lines are pushed to the left. I realize that it is a feature of the microtype package to push punctuation marks into the margin, but here it looks quite ugly because it isn't consistent. The first line is most likely different because of the included \item in \begin{quote}.

Is there a way to get the indention consistent? Can I temporarly disable this feature of microtype just for this environment? I'm having such code in some package manuals where some verbatim code lines which start with "punctuation" like { inside a quote environment.

\documentclass{article}
\usepackage{microtype}
\begin{document}
text text text text text text text text text text text text text text text text
\begin{quote}
    ()\\
    ()\\
    ()
\end{quote}
text text text text text text text text text text text text text text text text
\end{document}

Result

6
  • Originally I thought this has to do with the missing italic correction of the originally used font (tex.stackexchange.com/questions/13340/…) but after minimizing the file it turns out that is font independent. Mar 16, 2011 at 19:00
  • 2
    A local \microtypesetup{protrusion=false} works for me. Mar 16, 2011 at 19:14
  • @Andrey: This is what I was looking for! Please add it as answer. I don't know the microtype very well and didn't even know that this feature is called protrusion. It's not that obvious for an non-native speaker. Mar 16, 2011 at 20:18
  • 1
    I'd say that it's only a workaround to locally disable the protrusion. For your use case it might be OK, but in general it's not good to have inconsistent protrusion. Mar 16, 2011 at 21:01
  • 1
    Just a note that microtype now fixes this automatically (since v3.0)
    – Robert
    Oct 26, 2022 at 17:03

4 Answers 4

10

The suggested solution from the author of microtype is this:

\documentclass{article}
\usepackage{microtype}
\makeatletter
\newcommand*\protrudeleft[1]{%
    {\everypar{}%
     \setbox\z@\vbox{\noindent#1}%
     \vbadness=\@M
     \splittopskip=\z@
     \global\setbox\z@=\vsplit\z@ to \baselineskip
     \unvbox\z@ \global\setbox\z@=\lastbox
    }%
    \ifhbox\z@
      \leavevmode
      \kern\leftmarginkern\z@
    \fi
    #1}
\makeatother
\begin{document}
text text text text text text text text text text text text text text text
text
\begin{quote}
    \protrudeleft()\\
    ()\\
    ()
\end{quote}
text text text text text text text text text text text text text text text
text
\end{document}

Attention: You will perhaps have to put the argument of \protrudeleft in braces if is not a like here a simple character.

13
  • 1
    The drawback of this solution is that you have to remember to put the \protrudeleft. What would interest me: I'm not too sure about my own answer, does it also have disadvantages? It would be great if you can tell me. Mar 17, 2011 at 9:41
  • 1
    Your environment will not work as expected if the content contains lists. Include e.g. an itemize in the middle and see what happens. Also the protrusion problem affects all lists, e.g. an itemize and \protrudeleft helps there too. Mar 17, 2011 at 10:56
  • 1
    @Ulrike: Ah, I see, thanks. Could microtype solve this by patching the list environment so that it automatically starts with \protrudeleft if appropriate? Mar 17, 2011 at 11:08
  • 3
    Robert sent once a patch for the verse environment (in comp.text.tex, "character protruding and verses"), but said that it is rather fragile, that problems are to be expected and that "pdftex really needs a primitive to simulate line beginnings/ends". Mar 17, 2011 at 11:29
  • 2
    "pdftex really needs a primitive to simulate line beginnings/ends": Yes, indeed, this sounds like the Way to Go. Mar 17, 2011 at 12:58
16

Main microtype features can be enabled or disabled on the fly using the \microtypesetup command. In this case we need to locally disable character protrusion:

\documentclass{article}
\usepackage{microtype}

\newenvironment{example}{\microtypesetup{protrusion=false}%
  \begin{quote}}{\end{quote}}

\begin{document}
text text text text text text text text text text text text text text text text
\begin{example}
    ()\\
    ()\\
    ()
\end{example}
text text text text text text text text text text text text text text text text
\end{document}

This will, of course, have effect on all characters, be it () or any other symbol. An interesting task would be to selectively disable this feature if it should be kept enabled for symbols other than ().

9

I'd define my own microtype-safe environment to consistently have protrusion everywhere. Adjust the 3em to your needs:

\documentclass{article}
\usepackage{microtype}
\newenvironment{mtsafequote}
    {\par\bgroup\leftskip=3em\rightskip=3em\noindent\ignorespaces}
    {\par\egroup\noindent}
\begin{document}
text text text text text text text text text text text text text text text text
\begin{mtsafequote}
    ()\\
    ()\\
    ()
\end{mtsafequote}
text text text text text text text text text text text text text text text text
\end{document}
1
  • Thanks Henderik, for my very specific application this seems to be the way to go. I added something like this to ydoc now. As Ulrike states this seems to note suite for general quote like environments. Mar 17, 2011 at 11:42
6

Martin, here is the kernel of what is needed. I think you are better qualified than I am to wrap this up into a nicely robust redefined quote environment (or maybe fix it at the list, \item level):

\begin{quote}
    \quitvmode\kern\dimexpr-0.001em*\the\lpcode\font`(\relax()\\
    ()\\
    ()
\end{quote}

You must log in to answer this question.

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