[Tex/LaTex] Matlab LaTeX Interpreter: Minus sign in subscript or in superscript

math-operatorsMATLAB

In general, using Matlab with the LaTeX interpreter works fine. Today I focus a really stupid bug in the visualization of the minus sign.

In Matlab I write a text with the LaTeX string $K_{-1}$ and it simply shows the output of $K_{1}$. On the one hand the minus sign does not work. On the other hand the plus sign and plenty of other signs work.

I have found some "solutions" but they do not work.

  1. The first one tries to link another LaTeX version to the Matlab installation directory, so that Matlab should use the newer version of LaTeX. But it does not work for me.

    i solved this problem linking my latex installation inside the base latex directory of matlab

    1. rename (or delete if u prefer) /installation_matlab_path/matlab/sys/tex/latex/base in /installation_matlab_path/matlab/sys/tex/latex/old_base
    2. cd installation_matlab_path/matlab/sys/tex/latex/
    3. ln -s /usr/share/texmf-texlive/tex/latex/base/ base

    if u don't know where's your latex installation path just search for a file inside the tex/latex/base directory

  2. The second one uses additional braces to differenciate between the minus sign and the following characters but it does not work either.

    Instead of $^{-1}$, try $^{{-}1}$. That is include the minus sign in its own braces. It worked for me.

Perhaps, anyone can help me out with this problem.

Thanks!

Best Answer

Currently, I solved the problem by a small workaround but better / correct solutions are welcome. The workaround has been proposed by matheburg. Thanks for that!

Instead of $K_{-1}$, I now use $K_{\!^{\_}1}$. It sounds weird, but it looks similar to the minus sign. The underline is visible, so that I add an invisible negative space \! and take the underline \_ as superscript.

Related Question