9

I am using the following code to typeset a minus (or a plus) under a syllable of text to be used for chant:

\def\mi#1{$\displaystyle{\mathop{\mbox{\smash {#1}}}_{\scriptscriptstyle -}}$}

This provides a fairly satisfying result, but I want the text closer together. Other examples of \baselineskip or \fontsize have proved to be ineffective (or I am using them wrong).

Bl\textbf{e}ssed ind\textbf{e}ed \pl{is} the m\textbf{a}n\\*
who f\textbf{o}llows not the c\textbf{o}unsel \mi{of} \pl{the} w\textbf{i}c\mi{ked,}\

enter image description here

As a side note/problem, making the emphasized vowel bold the way I have done here separates it from the rest of the text and creates kerning problems - See the "o" of "follows" in the second line.

Qrrbrbirlbel
  • 119,821
ftherese
  • 161
  • By text are you referring to the +/- being closer to the text, or the spacing between the lines that need to be closer together, or both? – Werner May 03 '13 at 04:06
  • @Werner I think the proportions are basically good, but I'd like everything to be tighter. I don't really have a good eye for these things, but I know I'd like tighter spacing. – ftherese May 03 '13 at 09:58
  • is it ever possible for a plus to appear below a letter with a descender, as in "night"? (i.e., what if it were "night and day" rather than "day and night"?) – barbara beeton May 03 '13 at 13:31
  • @barbarabeeton http://oi43.tinypic.com/34pbdzb.jpg - here is a descender that nearly hits a plus sign. – ftherese May 04 '13 at 00:16
  • thanks for that example. @DavidCarlisle may want to consider adding this as a further illustration. (my philosophy is to look for the best "good bad examples" i can find, tune my approach to those, and thereby be pretty well assured that the solution will also work for the "usual" conditions.) – barbara beeton May 04 '13 at 12:05

1 Answers1

9

I'd use ooalign rather than mathop. This is about as close as you can go if you want the - aligned with the bar on + If you want the - to be raised more you could \smash it. I also introduced an optional parameter that allows you to give teh letter before the vowel so that it can measure if there would have been a kern, If so it kerns by half that amount (to take account of the bold being wider anyway).

enter image description here

\documentclass{article}
\parindent0pt

\def\pl#1{\oalign{\smash{#1}\cr\hfil$\scriptscriptstyle+$\hfil\cr}}
\def\mi#1{\oalign{\smash{#1}\cr\hfil$\scriptscriptstyle-$\hfil\cr}}

\newcommand\bv[2][]{%
  \ifx\relax#1\relax\textbf{#2}%
  \else
  \setbox0\hbox{#1#2}%
  \setbox2\hbox{#1\textbf{#2}}%
  #1\kern\dimexpr(\wd0-\wd2)/2\relax\textbf{#2}%
  \fi}

\begin{document}

Bl\textbf{e}ssed in\bv[d]{e}ed \pl{is} the m\bv{a}n\\*
who \bv[f]{o}llows not the c\textbf{o}unsel \mi{of} \pl{the} \bv[w]{i}c\mi{ked,}
\end{document}

Version as requested with extra space argument

\documentclass{article}
\parindent0pt
\parskip\baselineskip

\makeatletter
\def\pl#1{\oalign{\smash{#1}\cr\hfil$\scriptscriptstyle+$\hfil\cr}}
\def\mi#1{\oalign{\smash{#1}\cr\hfil$\scriptscriptstyle-$\hfil\cr}}
\newcommand\bv[1][]{\def\tmp{#1}\@bv}
\newcommand\@bv[2][\z@]{%
  \ifx\tmp\@empty
   \textbf{#2}%
  \else
  \setbox0\hbox{\tmp#2}%
  \setbox2\hbox{\tmp\textbf{#2}}%
  \tmp\kern\dimexpr(\wd0-\wd2)/2-#1\relax\textbf{#2}%
  \fi}
\makeatother

\begin{document}

Bl\textbf{e}ssed in\bv[d]{e}ed \pl{is} the m\bv{a}n\\*
who \bv[f]{o}llows not the c\textbf{o}unsel \mi{of} \pl{the} \bv[w]{i}c\mi{ked,}



Bl\textbf{e}ssed in\bv[d]{e}ed \pl{is} the m\bv{a}n\\*
who \bv[f][-2pt]{o}llows not the c\textbf{o}unsel \mi{of} \pl{the} \bv[w]{i}c\mi{ked,}

Bl\textbf{e}ssed in\bv[d]{e}ed \pl{is} the m\bv{a}n\\*
who \bv[f][2pt]{o}llows not the c\textbf{o}unsel \mi{of} \pl{the} \bv[w]{i}c\mi{ked,}
\end{document}

enter image description here


For thing letters the - might be wider than the letter forcing a space so hide most of the width by adding ! either side. Also in teh case of aw there is a kern between the letters normally that is lost, rather than add another optional argument for every possible combination this defines a \kernfix command so \kernfix a w inserts the kern that would have been between a and w, This results in

enter image description here

\documentclass{article}
\parindent0pt
\parskip\baselineskip

\makeatletter
\def\pl#1{\oalign{\smash{#1}\cr\hfil$\scriptscriptstyle\!+\!$\hfil\cr}}
\def\mi#1{\oalign{\smash{#1}\cr\hfil$\scriptscriptstyle\!-\!$\hfil\cr}}
\newcommand\bv[1][]{\def\tmp{#1}\@bv}
\newcommand\@bv[2][\z@]{%
\typeout{[[\tmp]][[#1]][[#2]]}%
  \ifx\tmp\@empty
   \textbf{#2}%
  \else
  \setbox0\hbox{\tmp#2}%
  \setbox2\hbox{\tmp\textbf{#2}}%
  \tmp\kern\dimexpr(\wd0-\wd2)/2-#1\relax\textbf{#2}%
  \fi}


\def\kernfix#1#2{%
  \setbox0\hbox{#1\kern\z@#2}%
  \setbox2\hbox{#1#2}%
  \kern\dimexpr\wd2-\wd0\relax}

\makeatother

\begin{document}

Bl\textbf{e}ssed in\bv[d]{e}ed \pl{is} the m\bv{a}n\\*
who \bv[f]{o}llows not the c\textbf{o}unsel \mi{of} \pl{the} \bv[w]{i}c\mi{ked,}


aaa  aw a\kern0pt w \mi{a}\pl{\bv[w]{a}y}! bbb


aaa  aw a\kern0pt w \mi{a}\kernfix{a}{w}\pl{\bv[w]{a}y}! bbb

Bl\textbf{e}ssed in\bv[d]{e}ed \pl{is} the m\bv{a}n\\*
who \bv[f][-2pt]{o}llows not the c\textbf{o}unsel \mi{of} \pl{the} \bv[w]{i}c\mi{ked,}

Bl\textbf{e}ssed in\bv[d]{e}ed \pl{is} the m\bv{a}n\\*
who \bv[f][2pt]{o}llows not the c\textbf{o}unsel \mi{of} \pl{the} \bv[w]{i}c\mi{ked,}
\end{document}

To get even smaller fonts use

\def\pl#1{\oalign{\smash{#1}\cr\hfil\fontsize{2pt}{2pt}\fontencoding{T1}\selectfont+\hfil\cr}}
\def\mi#1{\oalign{\smash{#1}\cr\hfil\fontsize{2pt}{2pt}\fontencoding{OMS}\selectfont\char0\hfil\cr}}

enter image description here

If you are using the default cm fonts you need to add

\RequirePackage{fix-cm}

before \documentclass to allow the fonts to scale that small.

David Carlisle
  • 757,742
  • I haven't tried \oalign before, but I'm not pleased with the result as the placement of the plus and minus are not aligned horizontally. On the other hand, I am very happy about a solution to the bold kerning problem! Here are other methods I have tried that were unsatisfactory: %\def\pl#1{\leavevmode\setbox0\hbox{#1}\setbox1\hbox to \wd0{\hss\raise1.5ex\hbox{\tiny{+}}\hss}{\vtop{\box0\box1}}} %\def\pl#1{$\smash{\underset{\text{\tiny{+}}}{\smash{\text{#1}}}}$} %\def\pl#1{$\underset{\text{\tiny +}}{\text{#1}}$} %\def\pl#1{$\stackrel{\hbox{#1}}{\hbox{\tiny +}}$} – ftherese May 03 '13 at 10:04
  • @ftherese see update: base smashed so that the plus and minus always align at same level. – David Carlisle May 03 '13 at 10:26
  • Wow - I've been working on this thing for years now. This is the solution. Just one final follow-up question: If I wanted to have granular control over the spacing (ie. add a few pixels of space) how could I do that? – ftherese May 03 '13 at 10:32
  • See update extra optional space argument added to \bv – David Carlisle May 03 '13 at 10:58
  • 1
    Oops! I should have been more specific - I meant to refer to the vertical space between the syllable and the plus or minus. A minus that comes under the character "g" in "night" for example, or a plus that comes next to "y" in "may" end up nearly touching. When it comes time to print we may want to give it a few more pixels of breathing room. – ftherese May 03 '13 at 11:07
  • 1
    @ftherese ah I had a 50-50 chance of being right:-) In that case \newcommand\pl[2][\z@]{\oalign{\smash{#2}\cr\noalign{\vskip#1}\hfil$\scriptscriptstyle+$\hfil\cr}} will give \pl an optional vertical shift argument (or for a given font you may want to change the default from \z@ (0pt) and always shift by a bit – David Carlisle May 03 '13 at 11:19
  • And... hopefully finally, how to deal with this situation:\mi{a}\pl{\bv[w]{a}y}! Which leaves a large gap between the "a" and the "way." – ftherese May 03 '13 at 11:25
  • last one, see update:-) – David Carlisle May 03 '13 at 11:51
  • @DavidCarlisle -- i think the bold "o" is still a bit too close to the "f". take a look at an all-lightface "follow" placed just above the adjusted version; the difference is easy to see -- the two words are the same width, and the bold "o" looks badly centered/kerned between "f" and "l". (when i get some time, i'll fiddle with this to see if i can come up with a generic improvement; it may be that "f" has to be treated as a special case -- although maybe just for computer modern, since that "f" is so wide.) – barbara beeton May 03 '13 at 13:28
  • @barbarabeeton (yes:-) you can use the optional argument in one of the variants posted above to shift it by 2sp or whatever though. (clearly the factor of half the kern for the non-bold font is purely arbitrary and not always perfect but a better default than 0pt) – David Carlisle May 03 '13 at 13:31
  • I'd like to get the pluses and minuses even smaller, but I am running into some kind of limit in mathmode font sizes. The smallest I can get is 5(pt?) using \DeclareMathSizes. – ftherese May 14 '13 at 10:12
  • @ftherese 2pt example added to answer – David Carlisle May 14 '13 at 10:35
  • @DavidCarlisle Thanks so much for that example! I added the bit from the other example you gave which enables a vertical fine tuning - perfect! – ftherese May 15 '13 at 13:51
  • @DavidCarlisle or ftherese: Is there a way to place these marks just above letter instead of below? – Ryan Jun 12 '14 at 13:11