GeneralNew Command with Math Mode inside

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
zaphod
Posts: 2
Joined: Thu Oct 18, 2012 4:35 pm

New Command with Math Mode inside

Post by zaphod »

Hello everyone,

I'm currently writing my master thesis and decided to do this with TeXmaker. I'm a total newcomer to LaTeX and TeXmaker and still make a lot of mistakes. This is the critical line:

Code: Select all

\newcommand{\photons}{\mu $ mol photons/m^{2}s $}
Every time I use the new command \photons I get the following error message:

Code: Select all

! Missing $ inserted.
<inserted text>
$
l.111 ...mum working PFD close to $ 200 $ \photons
for biomass growth }
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
Can you help me?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

New Command with Math Mode inside

Post by localghost »

Since \mu is a math mode symbol, it has to be put into math mode.

Code: Select all

\newcommand{\photons}{$\mu mol photons/m^{2}s$}
Untested due to missing minimal example.


Best regards and welcome to the board
Thorsten
zaphod
Posts: 2
Joined: Thu Oct 18, 2012 4:35 pm

Re: New Command with Math Mode inside

Post by zaphod »

Thanks for the fast reply!

Didn't know I should post a minimal example.
I'll do it the next time!

Thanks and by
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

New Command with Math Mode inside

Post by cgnieder »

zaphod wrote:Didn't know I should post a minimal example.
So you probably have neither read “Avoidable Mistakes” nor the “Board Rules”?

Regards
site moderator & package author
Post Reply