7

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.

8
  • 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. Oct 17, 2020 at 22:31
  • 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
    Oct 17, 2020 at 23:37
  • + 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. Oct 17, 2020 at 23:39
  • 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
    Oct 17, 2020 at 23:42
  • not sure what you mean by a global substitution, you mean replacing + by \resizebox{}{} in your editor? Yes that would work as well. Oct 17, 2020 at 23:45

3 Answers 3

8

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

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}
1

Here my solution for a + sign between text letters (inspired in this answer). It has following features:

  • I offer both a solution for capital (\Plus) and lower case (\plus) letters. For the lower case, I recommend to reduce the size.
  • I use a different syntax.

enter image description here

    \documentclass{article}
    \usepackage{calc}
    \usepackage{graphicx}
    
    %Plus for lower case
    \newlength{\heightofx}
    %Plus size is reduced to 60% (0.6)
    %and set at the mid height of 'x'
    \newcommand{\plus}{\settoheight{\heightofx}{x}%
    \raisebox{0.5\heightofx-(0.5\totalheight-\depth)}%
    {\scalebox{0.6}{+}}} 
    
    %Plus for captitals
    \newlength{\heightofX}
    %Plus is set at the mid height of 'X'
    \newcommand{\Plus}{\settoheight{\heightofX}{X}%
    \raisebox{0.5\heightofX-(0.5\totalheight-\depth)}{+}} 
    
    \begin{document}
    
    \begin{tabular}{cc}
    Adapted & Raw \\
    \hline
     \\[-0.5em]
    LOVE\Plus GRACE & LOVE+GRACE\\
    love\plus grace & love+grace
    \end{tabular}
    
    \end{document}
2
  • 1
    like a charm, thank you.
    – Duda
    Jan 27, 2022 at 9:16
  • @Duda my pleasure! Jan 27, 2022 at 11:51

You must log in to answer this question.

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