Error creating a newcommand which uses hspace
None of my newcommand
declarations work for hspace
, with or without arguments; I use the latest MathJax with the general libraries. Attempts so far:
newcommand{hs}[1]{hspace{#1}}
newcommand{hs}[1]{hspace{{#1}}}
newcommand{hs}[1]{hspace{{#1}px}}
newcommand{hs1}{hspace{10px}}
I have a pageful of other newcommand
declarations that work just fine, unsure what's failing here. Any remedy?
spacing macros errors mathjax
|
show 1 more comment
None of my newcommand
declarations work for hspace
, with or without arguments; I use the latest MathJax with the general libraries. Attempts so far:
newcommand{hs}[1]{hspace{#1}}
newcommand{hs}[1]{hspace{{#1}}}
newcommand{hs}[1]{hspace{{#1}px}}
newcommand{hs1}{hspace{10px}}
I have a pageful of other newcommand
declarations that work just fine, unsure what's failing here. Any remedy?
spacing macros errors mathjax
5
Welcome to TeX.SE! The command name has to be preceded by a backslash:newcommand{hs}[1]{hspace{#1}}
. Add a backslash and it will work. The and third versions add braces that shouldn't be there, so they won't work. The fourth version won't work because numbers can't be in command names, and the first optional argument tonewcommand
can't be empty.
– Phelype Oleinik
Jan 25 at 18:12
Note that mathjax is not LaTeX so you should probably not expect anynewcommand
to work.
– daleif
Jan 25 at 18:13
2
@daleifnewcommand
works in MathJax.
– egreg
Jan 25 at 18:24
@PhelypeOleinik Excellent, it works - thanks. Feel free to post your response as an answer if you'd like the answer credit.
– OverLordGoldDragon
Jan 25 at 18:34
@egreg out of the box with no extra configuration?
– daleif
Jan 25 at 19:16
|
show 1 more comment
None of my newcommand
declarations work for hspace
, with or without arguments; I use the latest MathJax with the general libraries. Attempts so far:
newcommand{hs}[1]{hspace{#1}}
newcommand{hs}[1]{hspace{{#1}}}
newcommand{hs}[1]{hspace{{#1}px}}
newcommand{hs1}{hspace{10px}}
I have a pageful of other newcommand
declarations that work just fine, unsure what's failing here. Any remedy?
spacing macros errors mathjax
None of my newcommand
declarations work for hspace
, with or without arguments; I use the latest MathJax with the general libraries. Attempts so far:
newcommand{hs}[1]{hspace{#1}}
newcommand{hs}[1]{hspace{{#1}}}
newcommand{hs}[1]{hspace{{#1}px}}
newcommand{hs1}{hspace{10px}}
I have a pageful of other newcommand
declarations that work just fine, unsure what's failing here. Any remedy?
spacing macros errors mathjax
spacing macros errors mathjax
edited Jan 25 at 23:05
Phelype Oleinik
22.3k54482
22.3k54482
asked Jan 25 at 18:03
OverLordGoldDragonOverLordGoldDragon
233
233
5
Welcome to TeX.SE! The command name has to be preceded by a backslash:newcommand{hs}[1]{hspace{#1}}
. Add a backslash and it will work. The and third versions add braces that shouldn't be there, so they won't work. The fourth version won't work because numbers can't be in command names, and the first optional argument tonewcommand
can't be empty.
– Phelype Oleinik
Jan 25 at 18:12
Note that mathjax is not LaTeX so you should probably not expect anynewcommand
to work.
– daleif
Jan 25 at 18:13
2
@daleifnewcommand
works in MathJax.
– egreg
Jan 25 at 18:24
@PhelypeOleinik Excellent, it works - thanks. Feel free to post your response as an answer if you'd like the answer credit.
– OverLordGoldDragon
Jan 25 at 18:34
@egreg out of the box with no extra configuration?
– daleif
Jan 25 at 19:16
|
show 1 more comment
5
Welcome to TeX.SE! The command name has to be preceded by a backslash:newcommand{hs}[1]{hspace{#1}}
. Add a backslash and it will work. The and third versions add braces that shouldn't be there, so they won't work. The fourth version won't work because numbers can't be in command names, and the first optional argument tonewcommand
can't be empty.
– Phelype Oleinik
Jan 25 at 18:12
Note that mathjax is not LaTeX so you should probably not expect anynewcommand
to work.
– daleif
Jan 25 at 18:13
2
@daleifnewcommand
works in MathJax.
– egreg
Jan 25 at 18:24
@PhelypeOleinik Excellent, it works - thanks. Feel free to post your response as an answer if you'd like the answer credit.
– OverLordGoldDragon
Jan 25 at 18:34
@egreg out of the box with no extra configuration?
– daleif
Jan 25 at 19:16
5
5
Welcome to TeX.SE! The command name has to be preceded by a backslash:
newcommand{hs}[1]{hspace{#1}}
. Add a backslash and it will work. The and third versions add braces that shouldn't be there, so they won't work. The fourth version won't work because numbers can't be in command names, and the first optional argument to newcommand
can't be empty.– Phelype Oleinik
Jan 25 at 18:12
Welcome to TeX.SE! The command name has to be preceded by a backslash:
newcommand{hs}[1]{hspace{#1}}
. Add a backslash and it will work. The and third versions add braces that shouldn't be there, so they won't work. The fourth version won't work because numbers can't be in command names, and the first optional argument to newcommand
can't be empty.– Phelype Oleinik
Jan 25 at 18:12
Note that mathjax is not LaTeX so you should probably not expect any
newcommand
to work.– daleif
Jan 25 at 18:13
Note that mathjax is not LaTeX so you should probably not expect any
newcommand
to work.– daleif
Jan 25 at 18:13
2
2
@daleif
newcommand
works in MathJax.– egreg
Jan 25 at 18:24
@daleif
newcommand
works in MathJax.– egreg
Jan 25 at 18:24
@PhelypeOleinik Excellent, it works - thanks. Feel free to post your response as an answer if you'd like the answer credit.
– OverLordGoldDragon
Jan 25 at 18:34
@PhelypeOleinik Excellent, it works - thanks. Feel free to post your response as an answer if you'd like the answer credit.
– OverLordGoldDragon
Jan 25 at 18:34
@egreg out of the box with no extra configuration?
– daleif
Jan 25 at 19:16
@egreg out of the box with no extra configuration?
– daleif
Jan 25 at 19:16
|
show 1 more comment
1 Answer
1
active
oldest
votes
In usual conditions, all commands in TeX must be preceded by a backslash, to tell TeX that they are commands, so instead of
newcommand{hs}[1]{hspace{#1}}
you need
newcommand{hs}[1]{hspace{#1}}
which will work as you expect.
Side note: If you just want to create a copy of a command with another name, you can use let
: leths=hspace
. With the newcommand
approach the hs
command will use hspace
, and with the let
approach it will be a copy of hspace
. One advantage of the latter is that hs*{argument}
will work as you'd expect. With newcommand
it won't.
The second version adds an extra pair of braces that shouldn't be there, so it won't work as well.
hspace{{1cm}}
will expand to hskip{#1}relax
, which isn't valid syntax and will throw you a Missing number
error.
The third version is the same. The unit will only appear after the Missing number
error, so it is of no use there. Besides, TeX doesn't know the unit px
, so even if you remove the braces you'll still get a Illegal unit of measure
.
The fourth contains, besides the illegal px
unit, two problems. The first is that in usual circumstances numbers aren't allowed in command names, so you can't use hs1
. The second is that the first optional argument of newcommand
(the number of arguments) must not be empty (). An empty argument is very different from a missing argument! If you try to do that (after removing the number from the command name) you'll get another
Missing number
error because LaTeX was expecting a number there.
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
});
}
});
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%2f471874%2ferror-creating-a-newcommand-which-uses-hspace%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In usual conditions, all commands in TeX must be preceded by a backslash, to tell TeX that they are commands, so instead of
newcommand{hs}[1]{hspace{#1}}
you need
newcommand{hs}[1]{hspace{#1}}
which will work as you expect.
Side note: If you just want to create a copy of a command with another name, you can use let
: leths=hspace
. With the newcommand
approach the hs
command will use hspace
, and with the let
approach it will be a copy of hspace
. One advantage of the latter is that hs*{argument}
will work as you'd expect. With newcommand
it won't.
The second version adds an extra pair of braces that shouldn't be there, so it won't work as well.
hspace{{1cm}}
will expand to hskip{#1}relax
, which isn't valid syntax and will throw you a Missing number
error.
The third version is the same. The unit will only appear after the Missing number
error, so it is of no use there. Besides, TeX doesn't know the unit px
, so even if you remove the braces you'll still get a Illegal unit of measure
.
The fourth contains, besides the illegal px
unit, two problems. The first is that in usual circumstances numbers aren't allowed in command names, so you can't use hs1
. The second is that the first optional argument of newcommand
(the number of arguments) must not be empty (). An empty argument is very different from a missing argument! If you try to do that (after removing the number from the command name) you'll get another
Missing number
error because LaTeX was expecting a number there.
add a comment |
In usual conditions, all commands in TeX must be preceded by a backslash, to tell TeX that they are commands, so instead of
newcommand{hs}[1]{hspace{#1}}
you need
newcommand{hs}[1]{hspace{#1}}
which will work as you expect.
Side note: If you just want to create a copy of a command with another name, you can use let
: leths=hspace
. With the newcommand
approach the hs
command will use hspace
, and with the let
approach it will be a copy of hspace
. One advantage of the latter is that hs*{argument}
will work as you'd expect. With newcommand
it won't.
The second version adds an extra pair of braces that shouldn't be there, so it won't work as well.
hspace{{1cm}}
will expand to hskip{#1}relax
, which isn't valid syntax and will throw you a Missing number
error.
The third version is the same. The unit will only appear after the Missing number
error, so it is of no use there. Besides, TeX doesn't know the unit px
, so even if you remove the braces you'll still get a Illegal unit of measure
.
The fourth contains, besides the illegal px
unit, two problems. The first is that in usual circumstances numbers aren't allowed in command names, so you can't use hs1
. The second is that the first optional argument of newcommand
(the number of arguments) must not be empty (). An empty argument is very different from a missing argument! If you try to do that (after removing the number from the command name) you'll get another
Missing number
error because LaTeX was expecting a number there.
add a comment |
In usual conditions, all commands in TeX must be preceded by a backslash, to tell TeX that they are commands, so instead of
newcommand{hs}[1]{hspace{#1}}
you need
newcommand{hs}[1]{hspace{#1}}
which will work as you expect.
Side note: If you just want to create a copy of a command with another name, you can use let
: leths=hspace
. With the newcommand
approach the hs
command will use hspace
, and with the let
approach it will be a copy of hspace
. One advantage of the latter is that hs*{argument}
will work as you'd expect. With newcommand
it won't.
The second version adds an extra pair of braces that shouldn't be there, so it won't work as well.
hspace{{1cm}}
will expand to hskip{#1}relax
, which isn't valid syntax and will throw you a Missing number
error.
The third version is the same. The unit will only appear after the Missing number
error, so it is of no use there. Besides, TeX doesn't know the unit px
, so even if you remove the braces you'll still get a Illegal unit of measure
.
The fourth contains, besides the illegal px
unit, two problems. The first is that in usual circumstances numbers aren't allowed in command names, so you can't use hs1
. The second is that the first optional argument of newcommand
(the number of arguments) must not be empty (). An empty argument is very different from a missing argument! If you try to do that (after removing the number from the command name) you'll get another
Missing number
error because LaTeX was expecting a number there.
In usual conditions, all commands in TeX must be preceded by a backslash, to tell TeX that they are commands, so instead of
newcommand{hs}[1]{hspace{#1}}
you need
newcommand{hs}[1]{hspace{#1}}
which will work as you expect.
Side note: If you just want to create a copy of a command with another name, you can use let
: leths=hspace
. With the newcommand
approach the hs
command will use hspace
, and with the let
approach it will be a copy of hspace
. One advantage of the latter is that hs*{argument}
will work as you'd expect. With newcommand
it won't.
The second version adds an extra pair of braces that shouldn't be there, so it won't work as well.
hspace{{1cm}}
will expand to hskip{#1}relax
, which isn't valid syntax and will throw you a Missing number
error.
The third version is the same. The unit will only appear after the Missing number
error, so it is of no use there. Besides, TeX doesn't know the unit px
, so even if you remove the braces you'll still get a Illegal unit of measure
.
The fourth contains, besides the illegal px
unit, two problems. The first is that in usual circumstances numbers aren't allowed in command names, so you can't use hs1
. The second is that the first optional argument of newcommand
(the number of arguments) must not be empty (). An empty argument is very different from a missing argument! If you try to do that (after removing the number from the command name) you'll get another
Missing number
error because LaTeX was expecting a number there.
answered Jan 25 at 18:49
Phelype OleinikPhelype Oleinik
22.3k54482
22.3k54482
add a comment |
add a comment |
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%2f471874%2ferror-creating-a-newcommand-which-uses-hspace%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
5
Welcome to TeX.SE! The command name has to be preceded by a backslash:
newcommand{hs}[1]{hspace{#1}}
. Add a backslash and it will work. The and third versions add braces that shouldn't be there, so they won't work. The fourth version won't work because numbers can't be in command names, and the first optional argument tonewcommand
can't be empty.– Phelype Oleinik
Jan 25 at 18:12
Note that mathjax is not LaTeX so you should probably not expect any
newcommand
to work.– daleif
Jan 25 at 18:13
2
@daleif
newcommand
works in MathJax.– egreg
Jan 25 at 18:24
@PhelypeOleinik Excellent, it works - thanks. Feel free to post your response as an answer if you'd like the answer credit.
– OverLordGoldDragon
Jan 25 at 18:34
@egreg out of the box with no extra configuration?
– daleif
Jan 25 at 19:16