## LaTeX forum ⇒ Text Formatting ⇒ Horizontal aligning superscript & subscript before a symbol Topic is solved

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
complexbuttons
Posts: 7
Joined: Sun Aug 19, 2012 10:41 pm

### Horizontal aligning superscript & subscript before a symbol

I need to have superscript and subscript before a symbol and superscript and subscript after it. Like this:

^n_m C ^p_q

However, sometimes n may be a longer string.

^{200000}_m C ^p_q

If I type that, m will appear at the same place where the 2 is. But m is supposed to be the pre-subscript of C, so it should be attached to C. It should be below the last 0 in 200000.

How to fix this?

Tags:

cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm
There are many different ways of doing this. Which one is the right one depends on what what you actually want to typeset:

(I've taken this list from here)

Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

complexbuttons
Posts: 7
Joined: Sun Aug 19, 2012 10:41 pm
MiKTeX says I have mhchem, but that command (\ce) and none of the others are recognized. I am using OooLatex. Why is a command not recognized despite me having the relevant package? Some other packages mentioned here are missing from my install. I have often tried to install a package and have never succeeded in getting it work.

EDIT: Found an answer here: http://latex-community.org/forum/viewtopic.php?f=5&t=10615! Apparently packages have something to do with a "LaTeX preamble". The first time I succeeded in installing a package!
Last edited by complexbuttons on Mon Aug 20, 2012 5:38 pm, edited 1 time in total.

cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm
I've never heard of OOoLatex before... in LyX you can add packages under document > settings > LaTeX Preamble

There you could add \usepackage[version=3]{mhchem}

Then you should be able to add the \ce command (as TeX code!).

Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

complexbuttons
Posts: 7
Joined: Sun Aug 19, 2012 10:41 pm
Thank you, the problem is now solved! I spent many days at this, so thank you very much!

complexbuttons
Posts: 7
Joined: Sun Aug 19, 2012 10:41 pm
Actually, there is still a problem. I can only use \ce or \ch. Using something else causes an error. But \ce puts the big character in italics, which I don't want. \ch puts small characters in non-italics, which I don't want. The center character should not be italic, but the rest should. Is there a way for me to disable the italics on the big character while using \ce?

Note: I have edited this post to better reflect my situation.
Last edited by cgnieder on Sun Sep 09, 2012 9:45 pm, edited 1 time in total.

cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm
I'm quite confident that the package installing issue has been discussed here before. A forum search should help.

Regarding the other issue: \ce is rather picky with regards of the input format of its argument. Even worse: the resulting effects if one doesn't obey the right format are rather unspecific and often contradictory. It took me a while to figure that out. (that's one of the reasons why \ch of the chemmacros package is much more strict in that matter).

You need to show me how you're using \ce else I could only guess why the format's going wrong in your case…

Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

complexbuttons
Posts: 7
Joined: Sun Aug 19, 2012 10:41 pm
\ce{^k_lS} is one example of how I'm using it.

cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm
This usage is correct. Either you are not using it this way or you maybe have an outdated or corrupted version of mhchem. The following minimal working example

\documentclass{article}\usepackage[version=3]{mhchem}\begin{document}\ce{^k_lS}\end{document}

gives

mhchem.png (1.46 KiB) Viewed 7855 times

Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

complexbuttons
Posts: 7
Joined: Sun Aug 19, 2012 10:41 pm
Yes, that is how it works. But I would like k and l to be italics. I don't know how do I prevent a fresh install of a package from being corrupted. I know the package name because you told it, but I don't know what version number I should use. Perhaps that would resolve the issue?

Also, it seems I can't even use \ch or \prescript. I don't remember how I made the formulae that had all characters in italics, because OooLaTeX omits the LaTeX code and only produces an image. I'm investigating this...

Edit: I managed to get \prescript work again. I had removed it from the preamble at some point. I cannot troubleshoot why \ch doesn't work, because the error message is too long to fit in the notification window, and it has no scrollbar. The preamble has \usepackage{chemmacros}.
Last edited by complexbuttons on Sun Sep 09, 2012 10:44 pm, edited 4 times in total.