3

I've copied a macro sequence from The Advanced TEXbook, p. 446. It supposed to put the accent#1 under the character#2.

\def\subaccent#1#2{\leavevmode\vtop{\setbox0=\hbox{#2}
\copy0\nointerlineskip\hbox to\wd0{\hss\char#1\hss}}}

I put the code into a self-written subaccent.sty file, then \usepackage{subaccent} in the preamble.

However, while calling the macro with \subaccent, the following error occurred:

! Missing number, treated as zero.
<to be read again>
\hss

I'm compiling with Lualatex. Can anyone tell me what's wrong with this macro?

  • You can just use amsmath's \underset: $\underset{\text{a}}{\text{b}}$ – Werner Sep 4 '15 at 20:12
  • The accents package has \underaccent{<accent>}{<character>} – clemens Sep 4 '15 at 20:15
  • \underaccent would definitely be preferable to \underset in this case. – barbara beeton Sep 4 '15 at 20:16
  • @barbarabeeton: True. – Werner Sep 4 '15 at 20:19
  • 1
    Remove \char: otherwise #1 should be a number, not a character. – egreg Sep 4 '15 at 20:24
2

The macro expects #1 to be a number. I suggest a modification based on my suspicion that you need it for undersetting a bar to a letter.

\documentclass[12pt, b5paper]{book}
\usepackage{fontspec}

\setmainfont{Calluna}

\newcommand{\ppacute}[1]{\accent"00B4 #1}
\newcommand{\ppbarunder}[1]{%
  \begingroup
  \sbox0{#1}%
  \setbox2=\vtop{
    \copy0
    \nointerlineskip
    \kern.1ex
    \hbox to\wd0{\hss\char"AF\hss}
  }%
  \dimen0=\dp0 \advance\dimen0 .25ex
  \dp2=\dimen0
  \leavevmode\box2
  \endgroup
}

\begin{document}
\fboxsep=0pt \fboxrule=0.1pt

aha\ppacute{m}tattva, rúpa, tanmátra

\ppacute{t} \ppbarunder{n} 
\fboxsep=0pt \fboxrule=0.1pt
\fbox{\ppbarunder{n}}
\fbox{\ppbarunder{g}}

\end{document}

The modification is necessary to remove the depth added by the fact that the character U+00AF has a height.

The two \fbox commands, together with the strange settings to \fboxrule and \fboxsep, are meant to show that the depth is set accurately.

enter image description here

If I add the code

\newcommand{\pphatunder}[1]{%
  \begingroup
  \setbox0=\hbox{#1}%
  \setbox2=\vtop{
    \copy0
    \nointerlineskip
    \kern0.05ex
    \hbox to\wd0{\hss\char"2C6\hss}
  }%
  \dimen0=\dp0 \advance\dimen0 .45ex
  \dp2=\dimen0
  \leavevmode\box2
  \endgroup
}

Then the input

\pphatunder{n}
\fboxsep=0pt \fboxrule=0.1pt
\fbox{\pphatunder{n}}
\fbox{\pphatunder{g}}

produces

enter image description here

The character U+02C6 is MODIFIER LETTER CIRCUMFLEX ACCENT.

  • Grazie mille @egreg! I would like to put ^ (actually it should be smaller, a circumflex) underneath n. But circumflex is not within the 128 characters of TeX character table, as far as I know. Any solution? – Roshnii Sep 4 '15 at 21:04
  • @Roshnii Does the addition seem good? – egreg Sep 4 '15 at 21:19
  • It works perfectly! Grazie mille mille! – Roshnii Sep 4 '15 at 21:33

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.