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

David Carlisle
  • 757,742
Martin Scharrer
  • 262,582
  • Originally I thought this has to do with the missing italic correction of the originally used font (http://tex.stackexchange.com/questions/13340/italic-correction-for-linux-libertine-font) but after minimizing the file it turns out that is font independent. – Martin Scharrer Mar 16 '11 at 19:00
  • 2
    A local \microtypesetup{protrusion=false} works for me. – Andrey Vihrov Mar 16 '11 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. – Martin Scharrer Mar 16 '11 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. – Hendrik Vogt Mar 16 '11 at 21:01
  • @Hendrik: I agree, that it the reason I didn't accepted Andrey's answer yet. I still think the \item in the quote is the clue. The protrusion doesn't work there. – Martin Scharrer Mar 16 '11 at 21:07
  • 1
    Just a note that microtype now fixes this automatically (since v3.0) – Robert Oct 26 '22 at 17:03

4 Answers4

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 ().

David Carlisle
  • 757,742
Andrey Vihrov
  • 22,325
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.

Ulrike Fischer
  • 327,261
  • 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. – Hendrik Vogt Mar 17 '11 at 09: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. – Ulrike Fischer Mar 17 '11 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? – Hendrik Vogt Mar 17 '11 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". – Ulrike Fischer Mar 17 '11 at 11:29
  • 2
    "pdftex really needs a primitive to simulate line beginnings/ends": Yes, indeed, this sounds like the Way to Go. – Hendrik Vogt Mar 17 '11 at 12:58
  • Ulrike, @Hendrik: I found this feature request for pdfTeX about simulated line beginnings/ends: http://sarovar.org/tracker/index.php?func=detail&aid=743&group_id=106&atid=496 – Martin Scharrer Mar 18 '11 at 20:28
  • @MartinScharrer Do you know if it has moved elsewhere? I (eventually) get an empty page at that address. – cfr Aug 26 '15 at 17:31
  • I stumbled across the exact problem described here. Is there meanwhile an accepted solution without a drawback? Can I redefine my quote environment to patch the first indended line? – johnny7 Mar 30 '22 at 16:23
  • @johnny7 this answer is 11 years old. And no you shouldn't use it (and with a currenty microtype it shouldn't be needed, it does that now automatically). – Ulrike Fischer Mar 30 '22 at 16:30
  • I was going to ask the exact same question and was happy to see it had already been asked before (not only here, but also here for example). But with TeX Live 2021 the problem with different indentation of the first quote line still stands for me and I haven't yet found a solution. I redefined: A workaround is to begin the quote environment with \par but that has unwanted side effects (different vertical spaces). – johnny7 Mar 30 '22 at 16:39
  • @johnny7 the example in the question above works fine for me in a up-to-date texlive 2021. – Ulrike Fischer Mar 30 '22 at 16:42
  • I redefined \renewenvironment{quote} {\list{}{\leftmargin0.5cm \rightmargin0cm} \item\relax\fontsize{9.8pt}{11.4pt}\selectfont} {\endlist} – johnny7 Mar 30 '22 at 16:43
  • @johnny7 don't ask new questions in a comment. If you changed something ask a new question. – Ulrike Fischer Mar 30 '22 at 16:43
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}
David Carlisle
  • 757,742
Hendrik Vogt
  • 37,935
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}
David Carlisle
  • 757,742
Lev Bishop
  • 45,462