Typing CO_2 easilynewcommand gives errors in math mode (with or without arguments)Macro shortcut for mathrm commandHow to implement expandbefore, similarly to expandafter?fancylabel not incrementing counter if table is include with ltxtableHow to typeset a word containing both Latin and Greek letters?
Why does this part of the Space Shuttle launch pad seem to be floating in air?
Can I use my Chinese passport to enter China after I acquired another citizenship?
Organic chemistry Iodoform Reaction
Is there a problem with hiding "forgot password" until it's needed?
Adding empty element to declared container without declaring type of element
General topology proving something for all of its points
Getting the lowest value with key in array
How do I repair my stair bannister?
Visiting the UK as unmarried couple
Should I stop contributing to retirement accounts?
Is there a word to describe the feeling of being transfixed out of horror?
Can I Retrieve Email Addresses from BCC?
Unmap "delete file" in Explore mode
When is separating the total wavefunction into a space part and a spin part possible?
Is it possible to have a strip of cold climate in the middle of a planet?
How did Monica know how to operate Carol's "designer"?
How to understand the output below from BGP?
What is the term when two people sing in harmony, but they aren't singing the same notes?
Have I saved too much for retirement so far?
JavaScript array of objects contains the same array data
Calculating the number of days between 2 dates in Excel
Watcher's of the Word Wall
Is it possible to build a CPA Secure encryption scheme which remains secure even when the encryption of secret key is given?
How many cookies does someone need to grab to be certain to obtain a flavor?
Typing CO_2 easily
newcommand gives errors in math mode (with or without arguments)Macro shortcut for mathrm commandHow to implement expandbefore, similarly to expandafter?fancylabel not incrementing counter if table is include with ltxtableHow to typeset a word containing both Latin and Greek letters?
I'm writing my dissertation and that involves typing a lot of $mathrmCO_2$. I'd like to make a macro for it that's a lot easier to type, but if I put newcommandco2mathrmCO_2, for example, it gives me the error that mathrm can only be used in math mode. But using newcommandco2$mathrmCO_2$ doesn't work either.
Is there a way for me to make a macro that makes typing CO_2 easier, even if it doesn't use mathrm?
chemistry
New contributor
Hayley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I'm writing my dissertation and that involves typing a lot of $mathrmCO_2$. I'd like to make a macro for it that's a lot easier to type, but if I put newcommandco2mathrmCO_2, for example, it gives me the error that mathrm can only be used in math mode. But using newcommandco2$mathrmCO_2$ doesn't work either.
Is there a way for me to make a macro that makes typing CO_2 easier, even if it doesn't use mathrm?
chemistry
New contributor
Hayley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Have you tried newcommandcotwomathrmCO_2 see tex.stackexchange.com/questions/44545/… also tex.stackexchange.com/questions/393855/…
– KJO
Mar 20 at 2:48
6
For anyone new to latex reading this question: There are two separate issues here. One is that mathrm can only be used in math mode. The second one is that you can't (usually) have digits in macro names.
– sgf
Mar 20 at 15:35
Oh I did not realize you couldn't have digits in macro names! Cool, thanks!
– Hayley
Mar 21 at 0:36
add a comment |
I'm writing my dissertation and that involves typing a lot of $mathrmCO_2$. I'd like to make a macro for it that's a lot easier to type, but if I put newcommandco2mathrmCO_2, for example, it gives me the error that mathrm can only be used in math mode. But using newcommandco2$mathrmCO_2$ doesn't work either.
Is there a way for me to make a macro that makes typing CO_2 easier, even if it doesn't use mathrm?
chemistry
New contributor
Hayley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I'm writing my dissertation and that involves typing a lot of $mathrmCO_2$. I'd like to make a macro for it that's a lot easier to type, but if I put newcommandco2mathrmCO_2, for example, it gives me the error that mathrm can only be used in math mode. But using newcommandco2$mathrmCO_2$ doesn't work either.
Is there a way for me to make a macro that makes typing CO_2 easier, even if it doesn't use mathrm?
chemistry
chemistry
New contributor
Hayley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Hayley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited Mar 20 at 11:03
Phelype Oleinik
24.6k54688
24.6k54688
New contributor
Hayley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Mar 20 at 2:02
HayleyHayley
785
785
New contributor
Hayley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Hayley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Hayley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Have you tried newcommandcotwomathrmCO_2 see tex.stackexchange.com/questions/44545/… also tex.stackexchange.com/questions/393855/…
– KJO
Mar 20 at 2:48
6
For anyone new to latex reading this question: There are two separate issues here. One is that mathrm can only be used in math mode. The second one is that you can't (usually) have digits in macro names.
– sgf
Mar 20 at 15:35
Oh I did not realize you couldn't have digits in macro names! Cool, thanks!
– Hayley
Mar 21 at 0:36
add a comment |
Have you tried newcommandcotwomathrmCO_2 see tex.stackexchange.com/questions/44545/… also tex.stackexchange.com/questions/393855/…
– KJO
Mar 20 at 2:48
6
For anyone new to latex reading this question: There are two separate issues here. One is that mathrm can only be used in math mode. The second one is that you can't (usually) have digits in macro names.
– sgf
Mar 20 at 15:35
Oh I did not realize you couldn't have digits in macro names! Cool, thanks!
– Hayley
Mar 21 at 0:36
Have you tried newcommandcotwomathrmCO_2 see tex.stackexchange.com/questions/44545/… also tex.stackexchange.com/questions/393855/…
– KJO
Mar 20 at 2:48
Have you tried newcommandcotwomathrmCO_2 see tex.stackexchange.com/questions/44545/… also tex.stackexchange.com/questions/393855/…
– KJO
Mar 20 at 2:48
6
6
For anyone new to latex reading this question: There are two separate issues here. One is that mathrm can only be used in math mode. The second one is that you can't (usually) have digits in macro names.
– sgf
Mar 20 at 15:35
For anyone new to latex reading this question: There are two separate issues here. One is that mathrm can only be used in math mode. The second one is that you can't (usually) have digits in macro names.
– sgf
Mar 20 at 15:35
Oh I did not realize you couldn't have digits in macro names! Cool, thanks!
– Hayley
Mar 21 at 0:36
Oh I did not realize you couldn't have digits in macro names! Cool, thanks!
– Hayley
Mar 21 at 0:36
add a comment |
3 Answers
3
active
oldest
votes
I'm not sure if this is a question about how to use co2 as a macro name or just a question about how to subscript in text mode. If you use coo, the macro
newcommandcooensuremathmathrmCO_2
works fine in both text and math mode. If you're only planning to use the macro in text mode, COtextsubscript2 works.

documentclassarticle
newcommandcooensuremathmathrmCO_2
newcommandcoooCOtextsubscript2
begindocument
With ensuremath: Text coo and math $coo$ both look fine.
With textsubscript: Text cooo is fine, but math $cooo$ isn't.
enddocument
Don't forget the trainling and space after the call in text mode.
Or usecooin text mode, which avoids worries about the space getting eaten by something.
– David Richerby
Mar 20 at 20:35
Perfect, thank you!
– Hayley
Mar 21 at 0:36
1
Especially when using macros, I think that using xspace is really convenient. You put anxspaceat the end of your macro and it will decide if a space is necessary or not.
– Ian
Mar 21 at 7:23
add a comment |
You want easy?
documentclassarticle
usepackagechemformula
begindocument
chCO2
enddocument
18
For completeness, you might mention alsomhchem
– egreg
Mar 20 at 9:04
add a comment |
I would use the mhchem package. It makes a lot of chemistry things easier, including reactions as well as formulas.
Put the line
usepackagemhchem
in the header section of your document, and then CO2 is just ceCO2. You can use that in math mode or text mode, it works either way. Here are some examples of other formulae from the package documentation, to give an idea of what you can do. (Note from the very first example how easy it is to write a simple reaction.)
(Note also that, as mentioned in John Kormylo's answer, there is also a package chemformula. It seems to be very similar, and allows you to do the same things in very similar ways. It is a more recent package, but I have no experience with it.)




add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Hayley is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480391%2ftyping-co-2-easily%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I'm not sure if this is a question about how to use co2 as a macro name or just a question about how to subscript in text mode. If you use coo, the macro
newcommandcooensuremathmathrmCO_2
works fine in both text and math mode. If you're only planning to use the macro in text mode, COtextsubscript2 works.

documentclassarticle
newcommandcooensuremathmathrmCO_2
newcommandcoooCOtextsubscript2
begindocument
With ensuremath: Text coo and math $coo$ both look fine.
With textsubscript: Text cooo is fine, but math $cooo$ isn't.
enddocument
Don't forget the trainling and space after the call in text mode.
Or usecooin text mode, which avoids worries about the space getting eaten by something.
– David Richerby
Mar 20 at 20:35
Perfect, thank you!
– Hayley
Mar 21 at 0:36
1
Especially when using macros, I think that using xspace is really convenient. You put anxspaceat the end of your macro and it will decide if a space is necessary or not.
– Ian
Mar 21 at 7:23
add a comment |
I'm not sure if this is a question about how to use co2 as a macro name or just a question about how to subscript in text mode. If you use coo, the macro
newcommandcooensuremathmathrmCO_2
works fine in both text and math mode. If you're only planning to use the macro in text mode, COtextsubscript2 works.

documentclassarticle
newcommandcooensuremathmathrmCO_2
newcommandcoooCOtextsubscript2
begindocument
With ensuremath: Text coo and math $coo$ both look fine.
With textsubscript: Text cooo is fine, but math $cooo$ isn't.
enddocument
Don't forget the trainling and space after the call in text mode.
Or usecooin text mode, which avoids worries about the space getting eaten by something.
– David Richerby
Mar 20 at 20:35
Perfect, thank you!
– Hayley
Mar 21 at 0:36
1
Especially when using macros, I think that using xspace is really convenient. You put anxspaceat the end of your macro and it will decide if a space is necessary or not.
– Ian
Mar 21 at 7:23
add a comment |
I'm not sure if this is a question about how to use co2 as a macro name or just a question about how to subscript in text mode. If you use coo, the macro
newcommandcooensuremathmathrmCO_2
works fine in both text and math mode. If you're only planning to use the macro in text mode, COtextsubscript2 works.

documentclassarticle
newcommandcooensuremathmathrmCO_2
newcommandcoooCOtextsubscript2
begindocument
With ensuremath: Text coo and math $coo$ both look fine.
With textsubscript: Text cooo is fine, but math $cooo$ isn't.
enddocument
Don't forget the trainling and space after the call in text mode.
I'm not sure if this is a question about how to use co2 as a macro name or just a question about how to subscript in text mode. If you use coo, the macro
newcommandcooensuremathmathrmCO_2
works fine in both text and math mode. If you're only planning to use the macro in text mode, COtextsubscript2 works.

documentclassarticle
newcommandcooensuremathmathrmCO_2
newcommandcoooCOtextsubscript2
begindocument
With ensuremath: Text coo and math $coo$ both look fine.
With textsubscript: Text cooo is fine, but math $cooo$ isn't.
enddocument
Don't forget the trainling and space after the call in text mode.
answered Mar 20 at 13:13
Sandy GSandy G
4,1751632
4,1751632
Or usecooin text mode, which avoids worries about the space getting eaten by something.
– David Richerby
Mar 20 at 20:35
Perfect, thank you!
– Hayley
Mar 21 at 0:36
1
Especially when using macros, I think that using xspace is really convenient. You put anxspaceat the end of your macro and it will decide if a space is necessary or not.
– Ian
Mar 21 at 7:23
add a comment |
Or usecooin text mode, which avoids worries about the space getting eaten by something.
– David Richerby
Mar 20 at 20:35
Perfect, thank you!
– Hayley
Mar 21 at 0:36
1
Especially when using macros, I think that using xspace is really convenient. You put anxspaceat the end of your macro and it will decide if a space is necessary or not.
– Ian
Mar 21 at 7:23
Or use
coo in text mode, which avoids worries about the space getting eaten by something.– David Richerby
Mar 20 at 20:35
Or use
coo in text mode, which avoids worries about the space getting eaten by something.– David Richerby
Mar 20 at 20:35
Perfect, thank you!
– Hayley
Mar 21 at 0:36
Perfect, thank you!
– Hayley
Mar 21 at 0:36
1
1
Especially when using macros, I think that using xspace is really convenient. You put an
xspace at the end of your macro and it will decide if a space is necessary or not.– Ian
Mar 21 at 7:23
Especially when using macros, I think that using xspace is really convenient. You put an
xspace at the end of your macro and it will decide if a space is necessary or not.– Ian
Mar 21 at 7:23
add a comment |
You want easy?
documentclassarticle
usepackagechemformula
begindocument
chCO2
enddocument
18
For completeness, you might mention alsomhchem
– egreg
Mar 20 at 9:04
add a comment |
You want easy?
documentclassarticle
usepackagechemformula
begindocument
chCO2
enddocument
18
For completeness, you might mention alsomhchem
– egreg
Mar 20 at 9:04
add a comment |
You want easy?
documentclassarticle
usepackagechemformula
begindocument
chCO2
enddocument
You want easy?
documentclassarticle
usepackagechemformula
begindocument
chCO2
enddocument
answered Mar 20 at 3:23
John KormyloJohn Kormylo
45.9k22672
45.9k22672
18
For completeness, you might mention alsomhchem
– egreg
Mar 20 at 9:04
add a comment |
18
For completeness, you might mention alsomhchem
– egreg
Mar 20 at 9:04
18
18
For completeness, you might mention also
mhchem– egreg
Mar 20 at 9:04
For completeness, you might mention also
mhchem– egreg
Mar 20 at 9:04
add a comment |
I would use the mhchem package. It makes a lot of chemistry things easier, including reactions as well as formulas.
Put the line
usepackagemhchem
in the header section of your document, and then CO2 is just ceCO2. You can use that in math mode or text mode, it works either way. Here are some examples of other formulae from the package documentation, to give an idea of what you can do. (Note from the very first example how easy it is to write a simple reaction.)
(Note also that, as mentioned in John Kormylo's answer, there is also a package chemformula. It seems to be very similar, and allows you to do the same things in very similar ways. It is a more recent package, but I have no experience with it.)




add a comment |
I would use the mhchem package. It makes a lot of chemistry things easier, including reactions as well as formulas.
Put the line
usepackagemhchem
in the header section of your document, and then CO2 is just ceCO2. You can use that in math mode or text mode, it works either way. Here are some examples of other formulae from the package documentation, to give an idea of what you can do. (Note from the very first example how easy it is to write a simple reaction.)
(Note also that, as mentioned in John Kormylo's answer, there is also a package chemformula. It seems to be very similar, and allows you to do the same things in very similar ways. It is a more recent package, but I have no experience with it.)




add a comment |
I would use the mhchem package. It makes a lot of chemistry things easier, including reactions as well as formulas.
Put the line
usepackagemhchem
in the header section of your document, and then CO2 is just ceCO2. You can use that in math mode or text mode, it works either way. Here are some examples of other formulae from the package documentation, to give an idea of what you can do. (Note from the very first example how easy it is to write a simple reaction.)
(Note also that, as mentioned in John Kormylo's answer, there is also a package chemformula. It seems to be very similar, and allows you to do the same things in very similar ways. It is a more recent package, but I have no experience with it.)




I would use the mhchem package. It makes a lot of chemistry things easier, including reactions as well as formulas.
Put the line
usepackagemhchem
in the header section of your document, and then CO2 is just ceCO2. You can use that in math mode or text mode, it works either way. Here are some examples of other formulae from the package documentation, to give an idea of what you can do. (Note from the very first example how easy it is to write a simple reaction.)
(Note also that, as mentioned in John Kormylo's answer, there is also a package chemformula. It seems to be very similar, and allows you to do the same things in very similar ways. It is a more recent package, but I have no experience with it.)




edited Mar 21 at 9:25
answered Mar 21 at 9:11
NathanielNathaniel
99721026
99721026
add a comment |
add a comment |
Hayley is a new contributor. Be nice, and check out our Code of Conduct.
Hayley is a new contributor. Be nice, and check out our Code of Conduct.
Hayley is a new contributor. Be nice, and check out our Code of Conduct.
Hayley is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480391%2ftyping-co-2-easily%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have you tried newcommandcotwomathrmCO_2 see tex.stackexchange.com/questions/44545/… also tex.stackexchange.com/questions/393855/…
– KJO
Mar 20 at 2:48
6
For anyone new to latex reading this question: There are two separate issues here. One is that mathrm can only be used in math mode. The second one is that you can't (usually) have digits in macro names.
– sgf
Mar 20 at 15:35
Oh I did not realize you couldn't have digits in macro names! Cool, thanks!
– Hayley
Mar 21 at 0:36