6

Macrons appear really wide on all characters, but especially so on the i. Is it possible to make them less wide?

\documentclass{article}
\begin{document}
Tac\=e, M\=arc\=o, \=unus, f\=\i li\=\i?
\end{document}

really wide macrons

Virdal
  • 157

2 Answers2

6

You can define a short one that matches the longer ones and fits quite well on the i like this:

\newcommand{\shortmacron}{%
   \makebox[0pt][l]{%
      \rule[1.3ex]{0.2em}{0.035em}%
   }%
}

Another way is to define a smart version that automatically adapts it’s length. I also set this one a little lower to minimize the conflict with the drop serif of the f

\newlength\tmp
\newcommand{\smartmacron}[1]{%
   \settowidth{\tmp}{#1}%
   \makebox[\tmp][c]{%
      \rule[1.2ex]{0.6\tmp}{0.035em}%
   }\kern-\tmp#1%
}

Using the xstring package to check which letter follows, we can define the macro even more smart and align the macron better on top of the letter:

\usepackage{xstring}
\newlength\tmpa
\newlength\tmpb
\newlength\tmpc
\newcommand{\supersmartmacron}[1]{%
   \settowidth{\tmpa}{#1}% width of letter
   \setlength{\tmpb}{0em}% x-shift
   \setlength{\tmpc}{1.23ex}% raise
   \IfStrEqCase{#1}{%
      {a} {\setlength{\tmpb}{-0.04em}}%
      {e} {\setlength{\tmpb}{-0.01em}}%
      {i} {\setlength{\tmpb}{-0.045em}\setlength{\tmpc}{1.8ex}}%
      {\i}{\setlength{\tmpb}{-0.045em}}%
      {o} {\setlength{\tmpb}{-0.01em}}%
      {u} {\setlength{\tmpb}{-0.04em}}%
   }
   \makebox[\tmpa][c]{%
      \kern\tmpb\rule[\tmpc]{0.6\tmpa}{0.035em}%
   }\kern-\tmpa#1%
}

Of curse the right values for the lengthen \tmpa, \tmpb and \tmpc depend on the selected typeface.

Result and demo code
(original macron, short macron, smart macron, super smart macron)

macrons

\documentclass{article}

\newcommand{\shortmacron}{%
   \makebox[0pt][l]{%
      \rule[1.3ex]{0.2em}{0.035em}%
   }%
}

\newlength\tmp
\newcommand{\smartmacron}[1]{%
   \settowidth{\tmp}{#1}%
   \makebox[\tmp][c]{%
      \rule[1.2ex]{0.6\tmp}{0.035em}%
   }\kern-\tmp#1%
}

\usepackage{xstring}
\newlength\tmpa
\newlength\tmpb
\newlength\tmpc
\newcommand{\supersmartmacron}[1]{%
   \settowidth{\tmpa}{#1}% width of letter
   \setlength{\tmpb}{0em}% x-shift
   \setlength{\tmpc}{1.23ex}% raise
   \IfStrEqCase{#1}{%
      {a} {\setlength{\tmpb}{-0.04em}}%
      {e} {\setlength{\tmpb}{-0.01em}}%
      {i} {\setlength{\tmpb}{-0.045em}\setlength{\tmpc}{1.8ex}}%
      {\i}{\setlength{\tmpb}{-0.045em}}%
      {o} {\setlength{\tmpb}{-0.01em}}%
      {u} {\setlength{\tmpb}{-0.04em}}%
   }
   \makebox[\tmpa][c]{%
      \kern\tmpb\rule[\tmpc]{0.6\tmpa}{0.035em}%
   }\kern-\tmpa#1%
}

\begin{document}
%\huge
%\tiny
Tac\=e, M\=arc\=o, \=unus, f\=\i li\=\i?

Tac\shortmacron e, M\shortmacron arc\shortmacron o, \shortmacron unus, f\shortmacron\i li\shortmacron\i?

Tac\smartmacron e, M\smartmacron arc\smartmacron o, \smartmacron unus, f\smartmacron\i li\smartmacron\i?

Tac\supersmartmacron e, M\supersmartmacron arc\supersmartmacron o, \supersmartmacron unus, f\supersmartmacron\i li\supersmartmacron\i?

\=a \shortmacron a

\=a \smartmacron a

\=a \supersmartmacron a\quad
\=e \supersmartmacron e\quad
\=i \supersmartmacron i\quad
\=\i \supersmartmacron \i\quad
\=o \supersmartmacron o\quad
\=u \supersmartmacron u\quad

\supersmartmacron a\quad
\supersmartmacron e\quad
\supersmartmacron i\quad
\supersmartmacron \i\quad
\supersmartmacron o\quad
\supersmartmacron u\quad
\end{document}

To use the shortcut with on of the smart versions call

\let\=\supersmartmacron

in your preamble.

Tobi
  • 56,353
  • You’re welcome! Please see my addition of \supersmartmarcon which gives even better results. – Tobi Aug 28 '15 at 08:59
0

Tobi's answer works wonderfully for lowercase letters in an upright font. I found myself putting macrons on uppercase letters in an Italic font, so I tweaked it to default to the letter's height and to apply a slant correction:

% \withoutpt as in the public domain file `samplepdf.tex'
{\catcode`\p=12 \catcode`\t=12 \gdef\WITHOUTPT#1pt{#1}}
 \def\withoutpt#1{\expandafter\WITHOUTPT#1} % returns float-like string

% New dimension to deal with slanted fonts \newlength\macronitalcorr % Let's name some of Tobi's parameters \newlength\macrongap \newlength\macronthickness \setlength{\macrongap}{0.23ex}% \setlength{\macronthickness}{0.035em}% thickness \newcommand{\macronscale}{0.6} % Fraction of letter covered % I have too many parameters--I can't remember what \tmpa means! \newlength\macronletterwidth % \tmpa \newlength\macronadjustment % \tmpb \newlength\macronheight % \tmpc

\newcommand{\superdupersmartmacron}[1]{{% % Extra brackets so commands will automatically reset \setlength{\macronadjustment}{0em}% x-shift \def\macroninputletter{#1}% \IfStrEqCase{#1}{% {a} {\setlength{\macronadjustment}{-0.04em}}% {e} {\setlength{\macronadjustment}{-0.01em}}% {i} {\setlength{\macronadjustment}{-0.045em}% \def\macronscale{0.95}% Wider macron over i \def\macroninputletter{\i}}% % Automatically use \i for i {I} {\def\macronscale{0.95}}% Wider macron over I {\i}{\setlength{\macronadjustment}{-0.045em}% \def\macronscale{0.95}}% Wider macron over i {o} {\setlength{\macronadjustment}{-0.01em}}% {u} {\setlength{\macronadjustment}{-0.04em}}% } \settoheight{\macronheight}{\macroninputletter}% \addtolength{\macronheight}{\macrongap}% % % If the font slants, how much do we move the macron? \macronitalcorr = \withoutpt\the\fontdimen 1 \the\font \macronheight % \settowidth{\macronletterwidth}{\macroninputletter}% width of letter \makebox[\macronletterwidth][c]{% \kern\macronadjustment% \kern \macronitalcorr \rule[\macronheight]{\macronscale\macronletterwidth} {\macronthickness}% \kern -\macronitalcorr% }\kern-\macronletterwidth\macroninputletter% }}

(A few other bells and whistles--I wanted macrons over is to be wider and to automatically replace i with \i.)

Chalkdust
  • 101