5

I have a lot of places in my dissertation where the plus sign appears surrounded by capital letters in text, e.g. NNLL+NNLO.
The problem is that by default, the + is aligned so low vertically, that among caps it looks badly aligned.
By playing around with the \raisebox, I found that it looks quite a bit better if raised by 0.25ex, and still looks fine with lowercase letters, even in situations like a+j.
Is there a way to change the default behavior of the plus sign to always appear raised in text?
I don't want to change what happens in the math mode.

I suppose a potential solution might be to globally substitute raw + by \raisebox{0.25ex}{+} (modulo the issue with space swallowing) or to make latex use a different font for rendering the +.
I just don't know if that's even possible.


Reporting on what I implemented based on the answers.
Here's the command I came up with that also accounts for bold and allows typesetting of two consecutive raised spaces with \++.

\makeatletter % https://tex.stackexchange.com/a/31660/35990
\newcommand*{\IfbfTF}{% detect bold font
  \ifx\f@series\my@test@bf
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}
\newcommand*{\my@test@bf}{bx}
\makeatother

% https://tex.stackexchange.com/a/567256/35990
\newcommand{\textplus}[1][+]{\raisebox{% font-independent height
  \dimexpr(\fontcharht\font`X-\height+\depth)/2\relax
}{\IfbfTF{$\bm{#1}$}{#1}}}

\ExplSyntaxOn
\NewDocumentCommand\+{}{
  \peek_charcode_remove:NTF + {\textplus[++]}{\textplus[+]}
}
\ExplSyntaxOff

\peek_charcode_remove:NTF requires the expl3 package.

  • I am not sure what you mean by "issue with space swallowing" ? + and \raisebox{0.25ex}{+} (and my suggested \+) all have the same behaviour with respect to surrounding white space. – David Carlisle 2 days ago
  • If you define \newcommand\myplus{+} and then write \myplus a, it is rendered as '+a' without a space. I assumed the same would also happen for \newcommand\+{+}, which seems to not be the case. Can anyone explain why? – SU3 2 days ago
  • + isn't a letter, so \+ terminates at the + just as \$ or \% but you hadn't mentioned a definition, so I thought you meant using \raisebox{..}{+} explicitly, which wouldn't drop spaces either. – David Carlisle 2 days ago
  • I also assumed that however a global substitution of + would work, it would internally rely on a new command definition and thus have the usual space problem. I clearly don't understand when space are swallowed and when not. – SU3 2 days ago
  • not sure what you mean by a global substitution, you mean replacing + by \resizebox{}{} in your editor? Yes that would work as well. – David Carlisle 2 days ago
7

I'm not sure that 0.25ex is the right choice: it actually makes the + sign to be slightly higher than a capital letter.

Using different fonts might also make the situation even worse. For instance, with Times you'd get

enter image description here

because here the + sign sits on the baseline. Can we make the raising independent of the font? Yes: a bit of algebra shows that we need to raise the symbol by half the sum of a capital letter, minus the height of + plus the height of +.

Using David's idea:

\newcommand{\+}{%
  \raisebox{\dimexpr(\fontcharht\font`X-\height+\depth)/2\relax}{+}%
}

Here's the output with Times

enter image description here

and with Computer Modern

enter image description here

Here's a visual proof of the statement about the height. The first + is with my definition, the second is raised 0.25ex. Just look at the top, because at the bottom TeX always uses the baseline.

enter image description here

| improve this answer | |
7

enter image description here

You could make + active and raise itself in text mode and not in math, but something would break, it is quite hard to catch all cases of \dimexpr \parindent + 5pt\relax and ensure you don't add a \raisebox mid-expression.

I would use a new command for it, \+ isn't defined by default so:

\documentclass{article}

\newcommand\+{\raisebox{0.25ex}{+}}
\begin{document}

NNLL+NNLO


NNLL\+NNLO

\end{document}
| improve this answer | |

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.