4

I'm writing a medicine/physiology article.

I was writing the manuscript in Microsoft Word, but have recently discovered LaTeX for rendering math equations, which it does superbly; and wanted to learn how to use LaTeX in text mode to write this article.

This is my first attempt using LaTeX text mode. I'm running MiKTeX 2.9 on a Windows XP laptop.

My article repeatedly uses standard physiology terminology for variables such as:

F\textsubscript{I}O\textsubscript{2}

(or $F_IO_2$ in math mode - but I know this is wrong to use this, as Math mode shouldn't be used to render text, and will italicise the subscripts!)

...or SI units such as:

L min\textsuperscript{-1)

(or $L min^(-1)$ in math mode)

I've read other discussions on the newsgroups regarding similar problems and have tried using the mchem add-in as a workaround; but this only recognises standard formulae used in chemistry, not physiology.

I'm using these units and variables very frequently in the text. There's got to be an easier way than writing \textsuperscript every time I want to write units, or writing \textsubscript twice every time I state a variable!

The whole point of using LaTeX for this exercise was to get away from Microsoft Word and the curse of its non-standard embedded control characters. However instead of being easier to use, the equivalent commands that I've found so far in LaTeX seem to take much more time and effort to write!

Are there other commands, macros or plug-ins that I could use instead to get the same job done with the minimum of keystrokes?

11
  • 1
    Variables are in math mode, with subscripts sometime of the form $F_{\mathrm{TEXT}}$ if that is appropriate (the subscript is a label rather than a variable). For units, I would point to me own siunitx package.
    – Joseph Wright
    Jan 19, 2013 at 16:35
  • You can use $\mathrm{F_IO_2}$.
    – Sigur
    Jan 19, 2013 at 16:37
  • Another variant — to make something like \def\Sub#1{\ensuremath{\mathrm{_{#1}}}} and \def\Sup#1{\ensuremath{\mathrm{^{#1}}}}. Then write F\Sub{I}O\Sup2
    – Eddy_Em
    Jan 19, 2013 at 16:44
  • 2
    @Dave It might be handy for those of not familiar with the area to have some idea of the meaning of 'F(I)O(2)' here, or perhaps better a link to a published paper/book showing how this is used.
    – Joseph Wright
    Jan 19, 2013 at 16:45
  • 2
    Welcome to TeX.sx! i notice that one of your examples has a negative superscript. that's a case where you really do want math mode; otherwise, the minus sign would be rendered as a hyphen, which isn't what you want. (if you find the minus sign too long, an en-dash would be better than a hyphen.) numerals are always presented in roman type in math, unless you go out of your way to do something else. Jan 19, 2013 at 16:55

3 Answers 3

5

I would probably define macros that internally actually use mhchem (which you've mentioned in your question) for these variables. For convenience one could define a macro that calls them by a key name. If I understand it correctly the variable part before the molecular formula should be typeset in italics?

For units @Joseph's siunitx is the way to go, IMHO.

Maybe something like this:

\documentclass{article}
\usepackage{siunitx}
\usepackage[version=3]{mhchem}

\makeatletter
\newcommand*\DeclarePhysio[3]{\@namedef{#1}{\ensuremath{#2}\ce{#3}}}
\newcommand*\physio[1]{\@nameuse{#1}}
\makeatother

% \DeclarePhysio{<key>}{<var>}{<chem>}
\DeclarePhysio{FIO2}{F_I}{O2}
\DeclarePhysio{FEO2}{F_E}{O2}
\DeclarePhysio{PaCO2}{P_a}{CO2}

\begin{document}

\physio{FIO2} or \physio{FEO2} or \physio{PaCO2}

\SI{.5}{\liter\per\minute} or a standalone unit: \si{\newton\per\kilo\gram}

\end{document}

enter image description here

2
  • Thanks all! To clarify re: Conventions for respiratory physiology units: Variable (F) should be Italic, Caps. Location (I) should be Subscript, Roman, Lower case unless in gaseous state, in which case use Caps. Gas (O2) should be all Subscript, Roman, Caps. Ref: Widdicombe J, Davies A. Respiratory Physiology (2nd ed.) 1991, Arnold, London; p13. Am exploring siunitx - looks brilliant, and very timely, as I'm currently writing another article on SI units in medicine...
    – Dave
    Jan 22, 2013 at 12:26
  • I could adapt the \DeclarePhysio to meet these conventions. Just to clarify on this: the whole chemical formula should be a subscript to the variable?
    – cgnieder
    Jan 22, 2013 at 12:42
3

With LaTeX you have several options for tailoring your working environment to suit your needs. If you like the effect of \textsubscript and \textsuperscript, you can define shortcuts for them:

\let\tsub=\textsubscript
\let\tsup=\textsuperscript

You can then write F\tsub{I}O\tsub{2} instead of the longer form.

Instead of names like \tsub, you could also use punctuation symbols (such as \.) as the names of your shortcuts. But be careful since most of them already have a meaning, which you'll need sooner or later.

Alternately, you could redefine _ and ^ so that they expand to \textsubscript/\textsuperscript in text mode, but they work as usual in math mode. This could lead to various complications (e.g., it can confuse some packages), so I recommend staying with the first option.

Defining your own commands for LaTeX is simple and robust (use \newcommand for less trivial shortcuts), and has the advantage that if you later change your mind about the best command or notation to use (perhaps due to some of the suggestions in the comments), you can just redefine your shortcuts instead of editing every use in your text.

Separately from the above, you can also speed things up by omitting the curly braces when the sub- or superscript is a single symbol (opinions differ on whether this is good LaTeX "style", but you're on solid ground if you're the only one editing your documents.) If both your shortcut and the sub- or superscript is a letter, you need a space to separate them, e.g. F\tsub I. But not so for a digit; you can write F\tsub IO\tsub2 and you get exactly the same as before.

4
  • But \sub and \sup are predefined commands (used in math mode). It is better to use a different name.
    – Aditya
    Jan 19, 2013 at 17:13
  • Oops, absolutely! I never use them by name so I forgot.
    – alexis
    Jan 19, 2013 at 19:16
  • I use them in macros when I am not sure that _ and ^ have their usual catcodes.
    – Aditya
    Jan 19, 2013 at 20:19
  • 2
    @Aditya They are \sb and \sp; however \sup is predefined for the "supremum" operator.
    – egreg
    Jan 19, 2013 at 23:22
0

I'm a big fan of \newcommand, so what I usually do when I need to use long commands several times in a document is to define a command that takes shorter time to write:

\newcommand{\mrm}{\mathrm}

This allows you to write \mrm{O_2} to produce O2, instead of \mathrm{O_2}. This is also great if you are writing about something with a very long title, a year you can't remember or whatever. Put `\newcommand{\ttl}{supercalifragilisticexpialidocious} in the preamble, and it saves you a lot of bother when writing an analysis of the song from Mary Poppins and so forth.

Be aware that there are pretty many commands written in LaTeX already, so you might hit upon an error. E.g. if you write \newcommand{\year}{1557} you will get an error saying the command is already defined. The smart thing to do is to try a different abbreviation in your command, such as \newcommand{\yr}{1557}; however you can use the \renewcommand{\year}{1557}, if you use it with caution. You may not always be aware of how LaTeX uses a command. If you were to redefine \year like I did above and then use the \maketitle command, it would look like you are writing a very old paper, since \maketitle uses \year in the date-field of the title.

The point of all this is that if you are fairly new to LaTeX and have not been bitten by the "things have to be done the correct way"-bug that all LaTeX users eventually get (trust me, I have a severe form myself), then \newcommand offers some good possibilities for easy and quick hacks and work-arounds.

You must log in to answer this question.

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