Typing CO_2 easily

Multi tool use
I'm writing my dissertation and that involves typing a lot of $mathrm{CO_2}$
. I'd like to make a macro for it that's a lot easier to type, but if I put newcommand{co2}{mathrm{CO_2}}
, for example, it gives me the error that mathrm
can only be used in math mode. But using newcommand{co2}{$mathrm{CO_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
?
macros
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 $mathrm{CO_2}$
. I'd like to make a macro for it that's a lot easier to type, but if I put newcommand{co2}{mathrm{CO_2}}
, for example, it gives me the error that mathrm
can only be used in math mode. But using newcommand{co2}{$mathrm{CO_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
?
macros
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.
Welcome to TeX.SE! Can you show a short compilable tex code resulting in your issue?
– Kurt
1 hour ago
Have you tried newcommand{cotwo}{mathrm{CO_2}} see tex.stackexchange.com/questions/44545/… also tex.stackexchange.com/questions/393855/…
– KJO
1 hour ago
add a comment |
I'm writing my dissertation and that involves typing a lot of $mathrm{CO_2}$
. I'd like to make a macro for it that's a lot easier to type, but if I put newcommand{co2}{mathrm{CO_2}}
, for example, it gives me the error that mathrm
can only be used in math mode. But using newcommand{co2}{$mathrm{CO_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
?
macros
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 $mathrm{CO_2}$
. I'd like to make a macro for it that's a lot easier to type, but if I put newcommand{co2}{mathrm{CO_2}}
, for example, it gives me the error that mathrm
can only be used in math mode. But using newcommand{co2}{$mathrm{CO_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
?
macros
macros
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 2 hours ago


Kurt
39.7k850164
39.7k850164
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 2 hours ago
HayleyHayley
1
1
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.
Welcome to TeX.SE! Can you show a short compilable tex code resulting in your issue?
– Kurt
1 hour ago
Have you tried newcommand{cotwo}{mathrm{CO_2}} see tex.stackexchange.com/questions/44545/… also tex.stackexchange.com/questions/393855/…
– KJO
1 hour ago
add a comment |
Welcome to TeX.SE! Can you show a short compilable tex code resulting in your issue?
– Kurt
1 hour ago
Have you tried newcommand{cotwo}{mathrm{CO_2}} see tex.stackexchange.com/questions/44545/… also tex.stackexchange.com/questions/393855/…
– KJO
1 hour ago
Welcome to TeX.SE! Can you show a short compilable tex code resulting in your issue?
– Kurt
1 hour ago
Welcome to TeX.SE! Can you show a short compilable tex code resulting in your issue?
– Kurt
1 hour ago
Have you tried newcommand{cotwo}{mathrm{CO_2}} see tex.stackexchange.com/questions/44545/… also tex.stackexchange.com/questions/393855/…
– KJO
1 hour ago
Have you tried newcommand{cotwo}{mathrm{CO_2}} see tex.stackexchange.com/questions/44545/… also tex.stackexchange.com/questions/393855/…
– KJO
1 hour ago
add a comment |
2 Answers
2
active
oldest
votes
You want easy?
documentclass{article}
usepackage{chemformula}
begin{document}
ch{CO2}
end{document}
Indeed, very easy. +1
– marmot
17 mins ago
add a comment |
documentclass[a4paper]{article}
makeatletter
newcommandUD@exchange[2]{#2#1}%
newcommandname{}%
longdefname#1#{romannumeral0@name{#1}}%
newcommand@name[2]{%
expandafterUD@exchangeexpandafter{csname#2endcsname}{ #1}%
}%
makeatother
% Variant 1: Via csname..endcsname define a macro whose name is CO_2
namenewcommand{CO_2}{$mathrm{CO_2}$}%
% Variant 2: Define a macro CO which as parameter text has the delimiter _2
newcommandCO{}%
defCO_2{$mathrm{CO_2}$}%
begin{document}
name{CO_2}
CO_2
end{document}
(I elaborated on the name
-macro in my answer to the question "How to implement expandbefore, similarly to expandafter?".)
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
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You want easy?
documentclass{article}
usepackage{chemformula}
begin{document}
ch{CO2}
end{document}
Indeed, very easy. +1
– marmot
17 mins ago
add a comment |
You want easy?
documentclass{article}
usepackage{chemformula}
begin{document}
ch{CO2}
end{document}
Indeed, very easy. +1
– marmot
17 mins ago
add a comment |
You want easy?
documentclass{article}
usepackage{chemformula}
begin{document}
ch{CO2}
end{document}
You want easy?
documentclass{article}
usepackage{chemformula}
begin{document}
ch{CO2}
end{document}
answered 49 mins ago


John KormyloJohn Kormylo
45.4k12570
45.4k12570
Indeed, very easy. +1
– marmot
17 mins ago
add a comment |
Indeed, very easy. +1
– marmot
17 mins ago
Indeed, very easy. +1
– marmot
17 mins ago
Indeed, very easy. +1
– marmot
17 mins ago
add a comment |
documentclass[a4paper]{article}
makeatletter
newcommandUD@exchange[2]{#2#1}%
newcommandname{}%
longdefname#1#{romannumeral0@name{#1}}%
newcommand@name[2]{%
expandafterUD@exchangeexpandafter{csname#2endcsname}{ #1}%
}%
makeatother
% Variant 1: Via csname..endcsname define a macro whose name is CO_2
namenewcommand{CO_2}{$mathrm{CO_2}$}%
% Variant 2: Define a macro CO which as parameter text has the delimiter _2
newcommandCO{}%
defCO_2{$mathrm{CO_2}$}%
begin{document}
name{CO_2}
CO_2
end{document}
(I elaborated on the name
-macro in my answer to the question "How to implement expandbefore, similarly to expandafter?".)
add a comment |
documentclass[a4paper]{article}
makeatletter
newcommandUD@exchange[2]{#2#1}%
newcommandname{}%
longdefname#1#{romannumeral0@name{#1}}%
newcommand@name[2]{%
expandafterUD@exchangeexpandafter{csname#2endcsname}{ #1}%
}%
makeatother
% Variant 1: Via csname..endcsname define a macro whose name is CO_2
namenewcommand{CO_2}{$mathrm{CO_2}$}%
% Variant 2: Define a macro CO which as parameter text has the delimiter _2
newcommandCO{}%
defCO_2{$mathrm{CO_2}$}%
begin{document}
name{CO_2}
CO_2
end{document}
(I elaborated on the name
-macro in my answer to the question "How to implement expandbefore, similarly to expandafter?".)
add a comment |
documentclass[a4paper]{article}
makeatletter
newcommandUD@exchange[2]{#2#1}%
newcommandname{}%
longdefname#1#{romannumeral0@name{#1}}%
newcommand@name[2]{%
expandafterUD@exchangeexpandafter{csname#2endcsname}{ #1}%
}%
makeatother
% Variant 1: Via csname..endcsname define a macro whose name is CO_2
namenewcommand{CO_2}{$mathrm{CO_2}$}%
% Variant 2: Define a macro CO which as parameter text has the delimiter _2
newcommandCO{}%
defCO_2{$mathrm{CO_2}$}%
begin{document}
name{CO_2}
CO_2
end{document}
(I elaborated on the name
-macro in my answer to the question "How to implement expandbefore, similarly to expandafter?".)
documentclass[a4paper]{article}
makeatletter
newcommandUD@exchange[2]{#2#1}%
newcommandname{}%
longdefname#1#{romannumeral0@name{#1}}%
newcommand@name[2]{%
expandafterUD@exchangeexpandafter{csname#2endcsname}{ #1}%
}%
makeatother
% Variant 1: Via csname..endcsname define a macro whose name is CO_2
namenewcommand{CO_2}{$mathrm{CO_2}$}%
% Variant 2: Define a macro CO which as parameter text has the delimiter _2
newcommandCO{}%
defCO_2{$mathrm{CO_2}$}%
begin{document}
name{CO_2}
CO_2
end{document}
(I elaborated on the name
-macro in my answer to the question "How to implement expandbefore, similarly to expandafter?".)
answered 52 mins ago
Ulrich DiezUlrich Diez
5,470619
5,470619
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
Fcrz,1A,x6,JzuGJ,z8q2qH4PSlKh2 jHb n0,jwk eyu,Ycm7PvXfYrF,1,h8,1BL1GyJA hH4x,8 sc,x0QS7,knM5qkY3MW wX
Welcome to TeX.SE! Can you show a short compilable tex code resulting in your issue?
– Kurt
1 hour ago
Have you tried newcommand{cotwo}{mathrm{CO_2}} see tex.stackexchange.com/questions/44545/… also tex.stackexchange.com/questions/393855/…
– KJO
1 hour ago