Latex options …
August 2, 2007 10:32 AM   Subscribe

A Latex question: So I am writing this theoretical CS paper in Latex and need to typeset math-y phrases that I can't seem to typeset just right. Detailed description inside …

My phrases include full words constants, so I have "stuff + crap" instead of "a + b" and of course there are lots more math-y symbols I use instead of a simple "+". Now, "stuff" looks yucky inside $$ and much better inside italics. I figured out two options to go about it:

1) Include my whole phrase inside $$ or in an "equation" environment, and then \mathit every word I need to.
2) Italicize my whole phrase in \emph and do a $$ for each math symbol I need in it.

I have a feeling both are quite hacky options. Is there a better option?

As for an example look at the phrases page 5 onward in this paper.
posted by raheel to Computers & Internet (6 answers total) 3 users marked this as a favorite
 
The "mathit" command switches to italics inside an equation:

\begin{equation}
\mathit{stuff} + \mathit{crap}
\end{equation}

Similarly, you have mathbf for boldface, mathsf for sans serif, mathrm for roman, etc.
posted by Johnny Assay at 10:45 AM on August 2, 2007


Best answer: I always say $\mathit{stuff} + \mathit{crap}$ for one-off things, or

% --- At the top, or in a separate file:
\newcommand{\stuff}{\mathit{stuff}}
\newcommand{\crap}{\mathit{crap}}

% --- in the text:
$\stuff + \crap$

if it's things I'm going to use a lot. For papers where I define a bunch of my own operators (i.e., all my papers), I define a bunch of LaTeX commands at the top and use them, e.g.:

% --- at the top or in a separate file:
\newcommand{\blobberize}[1]{\mathit{blobberize}({#1})}
\newcommand{\zap}[2]{\mathit{zap}({#1},{#2})}

% --- in the text:
The expression $\zap{\blobberize{X}}{\blobberize{\epsilon+\phi}}$ is a really great expression ...


This method is still painful, but hey, everything in LaTeX is painful.
posted by jacobm at 10:45 AM on August 2, 2007


I think using \mathit{word} is the least-hacky option. I think that's what \mathit and \mathrm were made for, basically.

And yeah, the second you do anything anywhere out-of-the ordinary, LaTeX gets really hacky really quick. Embrace it!
posted by marionnette en chaussette at 10:49 AM on August 2, 2007


Formatting of text inside of equations in Latex is indeed painful. I've encountered similar situations when writing chemical equations (where I want the letters that are part of chemical compounds to be in Roman, not italicized), and I basically just end up putting \mathrm{} around every word.

So I think \mathit{} it is.
posted by Kadin2048 at 11:11 AM on August 2, 2007


I just use \text{}.
posted by gleuschk at 11:23 AM on August 2, 2007


Best answer: If the thing you are working with is an equation, then you should be formatting it as an equation. This means use $$ ... $$, or better yet, \[ ... \] or \begin{equation} ...\end{equation}. It's somewhat irrelevant that inside your equation you've got words.

In this sort of situation, I also use \text{ ... }, since I think it looks better to have words not italicized, even if they're in an equation. However, and this is important! whether you like \text{} or \mathit{}, as jacobm mentioned above, if you are going to be referencing these items more than once, you really want to use a \newcommand{ } to define them.

You could even define a newcommand that ate whatever you fed it, if you've got a whole bunch of words which need to go into equations and you want them formatted in the same way.

E.g., in your preamble, add

\newcommand{\mi}[1]{\ensuremath{\mathit{#1}}}

%\ensuremath puts whatever it eats into mathmode, which is useful if you want to be able to use the command wherever you want; \mi for "make italic". I'm sure you could come up with a better name.

and you call it via:
\mi{stuff}

This way, when the referee or your advisor or you later on decide, darn, I used \text{ } but really they'd look better as sans-serif, you don't have to go through and change every instance; just change the definition.

Depending what books you've got handy and how you are going to be using your terms, if necessary you can define them to act like other kinds of math operators (e.g., binary operators or whatever). My personal favorite reference for that sort of stuff is _Math into LaTeX_, by George Grätzer.
posted by leahwrenn at 4:52 PM on August 2, 2007


« Older Surplus and clothing shops in San Diego...   |   HR people - please help me with a thorny resume... Newer »
This thread is closed to new comments.