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.

6
  • 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
    Commented May 3, 2013 at 4: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
    Commented May 3, 2013 at 9: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"?) Commented May 3, 2013 at 13:31
  • @barbarabeeton oi43.tinypic.com/34pbdzb.jpg - here is a descender that nearly hits a plus sign.
    – ftherese
    Commented May 4, 2013 at 0: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.) Commented May 4, 2013 at 12:05

1 Answer 1

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.

14
  • 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
    Commented May 3, 2013 at 10:04
  • @ftherese see update: base smashed so that the plus and minus always align at same level. Commented May 3, 2013 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
    Commented May 3, 2013 at 10:32
  • 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
    Commented May 3, 2013 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 Commented May 3, 2013 at 11:19

You must log in to answer this question.

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