I use Fourier as the mathematics font, but I found the subscripts for some letters be much too far away from the letter itself so it just looks broken (see (1)). Better would be (2) or maybe even (3).

Now, I can do this by hand, but I would have to do it every time so I want to redefine the \sigma command to automatically put the subscripts closer.

Also, there might be superscripts, which shouldn't be moved too close (see (4)) but rather like in (5).

Is there a way to realize this?




         \underbrace{\sigma_i \sigma_j}_{(1)} \quad
         \underbrace{\sigma_{\!i} \sigma_{\!j}}_{(2)} \quad
         \underbrace{\sigma_{\!\!i} \sigma_{\!\!j}}_{(3)} \\
         \underbrace{\sigma\!\!_{i}^2 \sigma\!\!_j^2}_{(4)} \quad
         \underbrace{\sigma_{\!\!i}^2 \sigma_{\!\!j}^2}_{(5)} \\

Without additional packages, you can redefine \sigma the following way


The \@ifnextchar checks if \sigma is followed by an underscore, which is then eaten away by \@gobble and the following token is passed to \closeindex. I used \DeclareRobustCommand to be able to use the command e.g. in figure captions.

Note that there are some cases which will break (but are to some extend also problematic with other solutions presented here):

  • Superscript must follow subscript, i.e. \sigma_i^2 works, while \sigma^2_i doesn't.
  • The underscore must follow explicitely, so \sigma\foo with \newcommand{\foo}{_i} is not treated.
  • Grouping is a bit different from normal behavior. E.g. normally, \sigma_\mathrm{i} would work, but doesn't here, but \sigma_{\mathrm{i}} does. The problem is, that pure \mathrm is treated as the next token and put into the subscipt. This could be fixed halfway by evaluating \mathrm earlier by adding two more \expandafters before \closeindex, but \mathrm{i} does not expand into a group, so effectively a \protect ends up in the subsript and the i follows at full height. So suggestions welcome to get this part working...
  • Thanks! This order of sub- and superscript makes sense (in many cases) anyway! The \sigma_{\mathrm{i}} problem is okay for the moment, but ideas are surely welcome. However, I like that your solution doesn't need additional parameters and is independent of a specific TeX engine! – seyfe Feb 10 '17 at 16:20

You may renew the \sigma command using an optional parameter for the underscript, not changing the way to put the superscript.

I've used etoolbox to test if the superscript is present or not:



    \sigma \quad
    \sigma[i] \sigma[j]  \quad
    \sigma[i]^2 \sigma[j]^2

enter image description here

  • Thanks for your answer! While I hoped for a possibility that would not require additional arguments to the command, this might be easiest solution without getting to deep into TeX (which, unfortunately, I don’t know how to, anyway). – seyfe Feb 10 '17 at 11:21
  • Meanwhile a I solution was posted which I like even better, so I chose to accept the other one. Still, I appreciate your effort! – seyfe Feb 10 '17 at 16:33

Here's a preprocessor-based approach that runs under LuaLaTeX. The code below makes different spacing adjustments depending on whether or not "j" is in subscript position.

enter image description here

The only restriction on input syntax is that any superscript terms must be specified after, not before, the subscript term. Thus, \sigma_i^2 will be processed correctly, but \sigma^2_i will not.

% !TeX program = lualatex

%>>>>>> add the following code to your preamble:
function change_sigma_subs ( s ) 
    s = string.gsub ( s , "\\sigma%s-_%s-(%b{})" , "\\sigma_{\\mkern-4mu %1}" )
    s = string.gsub ( s , "\\sigma%s-_%s-j"      , "\\sigma_{\\mkern-6mu j}"  )
    s = string.gsub ( s , "\\sigma%s-_%s-(%a)"   , "\\sigma_{\\mkern-4mu %1}" )
    return ( s )
\AtBeginDocument{\directlua{luatexbase.add_to_callback ( 
    "process_input_buffer", change_sigma_subs, "change_sigma_subs")}}

with adjustments:

$\sigma_{k} \sigma_{m} \quad \sigma_i \sigma_j \quad\sigma_{i-2}$

$A_{\sigma _ i \sigma _j}$ $A_{B_{\sigma_ i \sigma_j}}$

without adjustments:
\directlua{luatexbase.remove_from_callback ( 
    "process_input_buffer", "change_sigma_subs")}

$\sigma_{k} \sigma_{m} \quad \sigma_i \sigma_j \quad\sigma_{i-2}$

$A_{\sigma _ i \sigma _j}$ $A_{B_{\sigma_ i \sigma_j}}$

  • Thanks for the answer, but for the moment at least I would rather stick to a different tex engine (xtetex). Once I switch to luatex I will surely reconsider your code! – seyfe Feb 10 '17 at 11:17

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.