11

I want to make a command (to be used mainly with the beamer class) which typesets a text note with a dangerous bend sign \dbend on the left, the two vertically centered with respect to each other.

I've used a tabular environment with the m column provided by the array package:

\documentclass{standalone}
\usepackage{manfnt}
\usepackage{array}

\newcommand{\dnote}[1]{\begin{tabular}{@{}m{0.13\textwidth}@{}m{0.87\textwidth}@{}}\huge\dbend & {#1}\end{tabular}}

\begin{document}
\dnote{How much quacks would a TeXduck chuck if a TeXduck could chuck quacks? Would a TeXduck chuck quacks if quacks could chuck TeXducks?}
\end{document}

But the result is not what I expected, because the two are not centered (and with the standalone class, the bend is even clipped):

enter image description here

How can I fix this?

  • 3
    No ducks were harmed in the making of the command, only the bend symbol had been cut test after test. – Massimo Ortolano May 29 '16 at 21:25
  • Try x\fbox{\huge\dbend}x to see the geometry of the glyph (in article.cls). – Ulrike Fischer May 29 '16 at 21:42
  • @UlrikeFischer By the result it looks like the symbol has zero depth: am I correct? – Massimo Ortolano May 29 '16 at 21:49
11

Surprisingly enough, nobody has remarked yet that the manfnt package does provide a version of the \dbend command with the “ground” lifted to the level of the baseline, namely \textdbend. It suffices therefore to use this command instead of \dbend:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc} % not necessary here, but I prefer to use it
\usepackage{manfnt}
\usepackage{array}

\newcommand{\dnote}[1]{%
    \noindent % I guess this is intended...
    \begin{tabular}{@{}m{0.13\textwidth}@{}m{0.87\textwidth}@{}}%
        \huge\textdbend &#1%
    \end{tabular}%
    \par % ... and this too.
}



\begin{document}

\dnote{One-line note.}

\bigskip

\dnote{How much quacks would a TeXduck chuck if a TeXduck could chuck quacks?
Would a TeXduck chuck quacks if quacks could chuck TeXducks?}

\bigskip

\dnote{A longer note.  How much quacks would a TeXduck chuck if a TeXduck could
chuck quacks?  Would a TeXduck chuck quacks if quacks could chuck TeXducks?  How
much quacks would a TeXduck chuck if a TeXduck could chuck quacks?  Would a
TeXduck chuck quacks if quacks could chuck TeXducks?}

\bigskip

\dnote{And an even longer one; more precisely, one line longer than the previous
one.  How much quacks would a TeXduck chuck if a TeXduck could chuck quacks?
Would a TeXduck chuck quacks if quacks could chuck TeXducks?  How much quacks
would a TeXduck chuck if a TeXduck could chuck quacks?  Would a TeXduck chuck
quacks if quacks could chuck TeXducks?}

\end{document}

You can check that the output is quite satisfactory:

Output of the code

Allow me a brief digression here. It is well-known that the TeX source of The TeXbook is publicly available for educational purposes (only). Now, it may be interesting to remark that The TeXbook shows an evident example of “vertically centered” dangerous bend sign in the display on page vi (the sign of the display on page v is also vertically centered, but this may seem less evident); if you take a look to the TeX source to see how this is achived, you can guess that the segment that represents the “ground” on which the signal is stuck runs 11 points below the baseline, a fact that can be easily confirmed with a little experiment. This holds true for a font size of 10 points, that is, manfnt’s design size. At this size, the height of the \dbendcharacter is 7.5pt (you can measure it directly in TeX, or you can look it up in the TFM file, after converting it to a “Property List” file by giving the command

tftopl manfnt.tfm manfnt.pl

at your shell prompt). So, we see that the exact amount by which the character should be lifted is 11/7.5 = 22/15 of its height: this is exactly what the manfnt package does. Note that 22/15 = 1.466666666…, very close to @egreg’s guess of 1.475, but less close to Massimo’s, who proposed 1.2\height.

  • Fico! Thank you! At the beginning I hadn't included \noindent and \par because I used the command with the \beamer class, which does not indent by default, and I meant to use it just at the end of the slide, but in this way is more general. I obtained the 1.2\height by measuring the distances from the bounding box, but probably that's not the correct way. – Massimo Ortolano May 31 '16 at 11:08
  • @MassimoOrtolano: I beg your pardon: the distance from the bounding box of what? – GuM May 31 '16 at 21:24
  • Of the box obtained by compiling with the standalone class, actually the page boundaries. In the example reported in the OP I've used the standalone class which gives a box the size of the text. So I've measured the distance between the top and the bottom of the symbol and the box boundaries. – Massimo Ortolano May 31 '16 at 21:26
  • @MassimoOrtolano: I see. Thanks for the clarification. – GuM May 31 '16 at 21:29
7

The \dbend glyph has no depth, but it extends far below the baseline nonetheless. Look at the first line in the example below, with the correction with \raisebox.

\documentclass{article}
\usepackage{manfnt}
\usepackage{array}

\newcommand{\dnote}[1]{%
  \begin{tabular}{@{}m{0.13\textwidth}@{}m{0.87\textwidth}@{}}
  \raisebox{1.475\height}{\huge\dbend} & #1
  \end{tabular}%
}

\begin{document}

\fboxsep=0pt \fboxrule=0.1pt
X\fbox{\dbend}X\fbox{\raisebox{1.475\height}{\dbend}}X%

\bigskip\bigskip

\noindent
\dnote{How much quacks would a \TeX duck chuck if a \TeX duck could
chuck quacks? Would a \TeX duck chuck quacks if quacks could chuck \TeX ducks?}
\end{document}

enter image description here

Not vertically centered? Well, this is an inherent limitation of how the m column type is implemented.

  • I wouldn't worry too much about the vertical alignment – egreg May 29 '16 at 22:03
  • Raising by 1.2\height seems to yield a reasonable vertical alignment. – Massimo Ortolano May 29 '16 at 22:05
1

Changing the column-type to p instead of m for the text seems to fix this. Some clever person can probably answer as to why.

\documentclass{standalone}
\usepackage{manfnt}
\usepackage{array}

\newcommand{\dnote}[1]{\begin{tabular}{@{}m{0.13\textwidth}@{}p{0.87\textwidth}@{}}\huge\dbend & {#1}\end{tabular}}

\begin{document}
\dnote{How much quacks would a TeXduck chuck if a TeXduck could chuck quacks? Would a TeXduck chuck quacks if quacks could chuck TeXducks?}
\end{document}

enter image description here

  • The symbol and the text are still not vertically centered, though. You can see it by increasing the length of the text. – Massimo Ortolano May 29 '16 at 21:41

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.