3

I would like to add a pair of gray quotation marks around the text without affecting the surrounded text. For this I tried to use \makebox with zero width. However, I was still getting:

enter image description here

To my understanding, as the box has zero width, I should get vertically aligned text. I suspect that this may have something to do with the \leavevmode inside \makebox, but I don't know how to properly cancel this extra horizontal spacing.

Below is a minimal working example.

\documentclass{article}

\usepackage{xcolor}
\usepackage{blindtext}

\ExplSyntaxOn

\NewDocumentEnvironment { excerpt } { }
  {
    \raisebox{-.5ex}{\makebox[0pt]{\Large\textcolor{gray!55}{``}}}
  }
  {
    \unskip \nobreakspace
    \raisebox{-.5ex}{\makebox[0pt]{\Large\textcolor{gray!55}{''}}}
  }

\ExplSyntaxOff

\begin{document}

\blindtext

\begin{excerpt}
  \blindtext
\end{excerpt}

\begin{excerpt}
  Text for testing.
\end{excerpt}

Text for testing.

\end{document}

2 Answers 2

2

You don't want \makebox[0pt]{...}, but either \makebox[0pt][r]{...} or \makebox[0pt][l]{...}, besides better controlling spaces.

\documentclass{article}

\usepackage{xcolor}
\usepackage{blindtext}

\NewDocumentEnvironment{excerpt}{}
  {%
    \raisebox{-.5ex}{\makebox[0pt][r]{\Large\textcolor{gray!55}{``}}}\ignorespaces
  }
  {%
    \unskip
    \raisebox{-.5ex}{\makebox[0pt][l]{\Large\textcolor{gray!55}{''}}}\ignorespacesafterend
  }

\begin{document}

\blindtext

\begin{excerpt}
  \blindtext
\end{excerpt}

\begin{excerpt}
  Text for testing.
\end{excerpt}

Text for testing.

\end{document}

enter image description here

1

I suggest you use \llap for the start. And use \ignorespaces. For the end you don't need any width adjustment. I commented out the \nobreakspace there.

\documentclass{article}

\usepackage{xcolor}
\usepackage{blindtext}

\ExplSyntaxOn

\NewDocumentEnvironment { excerpt } { }
  {
    \raisebox{-.5ex}{\llap{\Large\textcolor{gray!55}{``}}}
    \ignorespaces
  }
  {
    \unskip 
    %\nobreakspace
    \raisebox{-.5ex}{\Large\textcolor{gray!55}{''}}
  }

\ExplSyntaxOff

\begin{document}

\blindtext

\begin{excerpt}
  \blindtext
\end{excerpt}

\begin{excerpt}
  Text for testing.
\end{excerpt}

Text for testing.

\end{document}

output with quotes

You must log in to answer this question.

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