Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
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 3 '13 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 May 3 '13 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"?) –  barbara beeton May 3 '13 at 13:31
    
@barbarabeeton oi43.tinypic.com/34pbdzb.jpg - here is a descender that nearly hits a plus sign. –  ftherese May 4 '13 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.) –  barbara beeton May 4 '13 at 12:05

1 Answer 1

up vote 9 down vote accepted

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.

share|improve this answer
    
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 3 '13 at 10:04
    
@ftherese see update: base smashed so that the plus and minus always align at same level. –  David Carlisle May 3 '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 3 '13 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 May 3 '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$\scriptscrip‌​tstyle+$\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 3 '13 at 11:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.