Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is it possible to use math commands in text without using $..$ or \(..\) as for example:

 ... testing \alpha more text
share|improve this question
4  
When writing math symbols you'll want math spacing, so instead of avoiding writing certain things you should make it easier to write certain things, see e.g. tex.stackexchange.com/questions/30631/… –  N.N. Oct 8 '11 at 9:58
add comment

4 Answers

While it's possible to coax LaTeX into allowing

... testing \alpha more text

or similar input, this opens the door to

... testing \alpha+\beta more text

or, even worse, to

... testing \alpha-\beta more text

which would give something we are, regrettably, used to see in poorly typeset documents. Getting trained into writing

\(\alpha\)

will help the typist to keep math properly segregated, so that TeX will be able to apply its special math processing.

Added

If all you need is to type Greek words, as opposed to math symbols, the road is different: put

\usepackage[greek,english]{babel}

in your preamble. If you already use babel, add the greek option as the first one. Then

\textgreek{ABGDEZHJIKLMNXOPRSTUFQYW abgdezhjiklmnxoprstufqyw}

will typeset the Greek lowercase alphabet. The "tonos" can be input as a prefix apostrophe:

\textgreek{Ag'ia Sof'ia (Kwnstantino'upolh)}

will print Αγία Σοφία (Κωνσταντινούπολη)

There's also support for polytonic Greek.

share|improve this answer
add comment

You will need first to store the original commands using \let:

 \let\storeAlpha=\alpha

and then redefine the command, here is a minimal:

\documentclass[10pt,a4paper]{article}
\usepackage{xspace}
\begin{document}
\let\storeAlpha=\alpha
\renewcommand\alpha{\relax\ifmmode{\storeAlpha}\else{$\storeAlpha$}\fi\xspace}
%% another way is to use \ensuremath

\let\storeBeta=\beta
\renewcommand\beta{\ensuremath{\beta}}

This is an \alpha and an $\alpha$ and an \(\alpha\) and a \beta.
\end{document}

The \ifmmode checks if TeX is in mathmode, if is true it will use the original command, otherwise the $..$ are inserted.

share|improve this answer
1  
You could use \ensuremath here to make life a bit less wordy. –  Joseph Wright Oct 8 '11 at 7:49
    
@Joseph I will add a note, thought this one would make a good example to illustrate math mode, but you right it is very wordy. –  Yiannis Lazarides Oct 8 '11 at 8:00
add comment

All answers have mentioned using the alpha from the math font. If you are looking for typesetting a Greek word then you should use alpha from a text font. I don't know about LaTeX, but in ConTeXt there are two ways to use Greek letters from the text fonts. For both cases, you need to use a text font that has Greek letters (TeX Gyre Fonts have that, LM does not).

\setupbodyfont[palatino]

\starttext
\startTEXpage[width=6cm, offset=2mm]
There are two ways to get Greek letters in text mode:
\startitemize[n][headstyle=bold]
  \head Type them directly

    αβγδε \unknown

  \head Use \type{\greek...} macros

    \greekalpha\greekbeta\greekgamma\greekdelta\unknown
\stopitemize

Notice that text Greek symbols αβγδε differ from math Greek symbols $αβγδε$.
\stopTEXpage
\stoptext

which gives

enter image description here

share|improve this answer
add comment

Sorry, but it is not possible to write math control sequences without placing them in a math environment such as $...$ Or $$...$$ or \[...\]. The only way I can see you doing this is by defining the control sequence you want using some of the several methods, but I will choose to use the ensuremath, to make sure that no matter what environment you are using your math commands in, the compiler will not complain to you and give you millions of errors.

Such as:

MWE:

\documentclass{article}

\def\alp{\ensuremath{\alpha} }

\begin{document}

This is a test that \alp works inside of the text-mode environment.

\end{document}

Which produces:

alpha

So this is one way to get the job done.

Hope this helped.

EDIT: As egreg kindly pointed out to me. The $$...$$ should not be used for display math instead use -> \[...\] as an "equivalent" (minus the spacing issues $$...$$ gives) alternative.

share|improve this answer
6  
Since you are talking about LaTeX, please don't mention $$...$$. –  egreg Oct 8 '11 at 9:39
    
Thanks for the reminder. Even though I stopped using it myself, some others still do, but I shall not encourage it I guess. –  night owl Oct 9 '11 at 9:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.