How to get rid of leading zeros in a number?What is the proper way to pass user input to package commands?Double #s when defining a new command that uses mint instead of using mint directlyCompletely hermetic, local TeX installParametrized inclusion of sub-filesedit an environment to add to a new extra parameterHow to use $texinputs in Powershellxparse g argument should be avoided?Define macro as wrapper for parameters of a commandHow to implement expandbefore, similarly to expandafter?How can I grow the height of a function letter to match the height of the parameters?
Is Illustrator accurate for business card sizes?
How to draw twisted cuves?
Define tcolorbox in math mode
Skipping same old introductions
How to avoid a lengthy conversation with someone from the neighborhood I don't share interests with
If a Shadow Magic sorcerer casts Darkness using the Eyes of the Dark feature, can they cast another spell that requires concentration?
Why are Star Wars Rebel Alliance ships named after letters from the Latin alphabet?
How is Sword Coast North governed?
Can it be useful for a player block with a hanging piece in a back rank mate situation?
Why are prop blades not shaped like household fan blades?
How to power down external drive safely
Can I say "Gesundheit" if someone is coughing?
What is the most 'environmentally friendly' way to learn to fly?
The grades of the students in a class
How to trick a fairly simplistic kill-counter?
How can a class have multiple methods without breaking the single responsibility principle
What's the proper way of indicating that a car has reached its destination during a dialogue?
Why do player start with fighting for the corners in go?
Will medical institutions reject an applicant based on being 28 years of age?
Move label of an angle in Tikz
Ernie and the Superconducting Boxes
Overprovisioning SSD on ubuntu. How? Ubuntu 19.04 Samsung SSD 860
Applying for mortgage when living together but only one will be on the mortgage
Need help in optimizing the below helper class
How to get rid of leading zeros in a number?
What is the proper way to pass user input to package commands?Double #s when defining a new command that uses mint instead of using mint directlyCompletely hermetic, local TeX installParametrized inclusion of sub-filesedit an environment to add to a new extra parameterHow to use $texinputs in Powershellxparse g argument should be avoided?Define macro as wrapper for parameters of a commandHow to implement expandbefore, similarly to expandafter?How can I grow the height of a function letter to match the height of the parameters?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to check user input (a number parameter) for leading zeros and remove them. I wonder if such command is provided by LaTeX2e, or by one of the engines (pdftex, xetex).
parameters texinputs
add a comment |
I'm trying to check user input (a number parameter) for leading zeros and remove them. I wonder if such command is provided by LaTeX2e, or by one of the engines (pdftex, xetex).
parameters texinputs
1
number0000123will print123(notice the trailing space).
– egreg
12 hours ago
add a comment |
I'm trying to check user input (a number parameter) for leading zeros and remove them. I wonder if such command is provided by LaTeX2e, or by one of the engines (pdftex, xetex).
parameters texinputs
I'm trying to check user input (a number parameter) for leading zeros and remove them. I wonder if such command is provided by LaTeX2e, or by one of the engines (pdftex, xetex).
parameters texinputs
parameters texinputs
asked 12 hours ago
bp2017bp2017
1,5163 silver badges17 bronze badges
1,5163 silver badges17 bronze badges
1
number0000123will print123(notice the trailing space).
– egreg
12 hours ago
add a comment |
1
number0000123will print123(notice the trailing space).
– egreg
12 hours ago
1
1
number0000123 will print 123 (notice the trailing space).– egreg
12 hours ago
number0000123 will print 123 (notice the trailing space).– egreg
12 hours ago
add a comment |
1 Answer
1
active
oldest
votes
number
See egreg's comment, for the simplest solution for integer numbers in the range -2147483647 to 2147483647:
number000123⌴
number-000456⌴
Result: 123 and -456
The space, marked with ⌴ ends the parsing of the number and prevents accident if digits are following in the normal text.
This solution is expandable and can be used inside csname, label, typeout, for example.
Package bigintcalc
This package provides an expandable method for removing leading zeros from integer numbers that are arbitrary large. From the documentation:
bigintcalcNum ⟨x⟩
Macro
bigintcalcNumconverts its argument to a normalized integer
number without unnecessary leading zeros or signs. The result matches
the regular expression:0|-?[1-9][0-9]*
Example:
usepackagebigintcalc% plain TeX: input bigintcalc.sty
...
bigintcalcNum000123456789123456789123456789
bigintcalcNum-000123456789123456789123456789
Result: 123456789123456789123456789 and -123456789123456789123456789
The macro is expandable, the package can be used with lots of TeX flavors (LaTeX, plain TeX, iniTeX, ...)
Package siunitx
If the number is to be intended to be printed, package siunitx offers lots of options to format the number. By default, leading zeros are removed:
documentclassarticle
usepackagesiunitx
begindocument
num000123; num-000456
enddocument
Result: 123; -456
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%2f502670%2fhow-to-get-rid-of-leading-zeros-in-a-number%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
number
See egreg's comment, for the simplest solution for integer numbers in the range -2147483647 to 2147483647:
number000123⌴
number-000456⌴
Result: 123 and -456
The space, marked with ⌴ ends the parsing of the number and prevents accident if digits are following in the normal text.
This solution is expandable and can be used inside csname, label, typeout, for example.
Package bigintcalc
This package provides an expandable method for removing leading zeros from integer numbers that are arbitrary large. From the documentation:
bigintcalcNum ⟨x⟩
Macro
bigintcalcNumconverts its argument to a normalized integer
number without unnecessary leading zeros or signs. The result matches
the regular expression:0|-?[1-9][0-9]*
Example:
usepackagebigintcalc% plain TeX: input bigintcalc.sty
...
bigintcalcNum000123456789123456789123456789
bigintcalcNum-000123456789123456789123456789
Result: 123456789123456789123456789 and -123456789123456789123456789
The macro is expandable, the package can be used with lots of TeX flavors (LaTeX, plain TeX, iniTeX, ...)
Package siunitx
If the number is to be intended to be printed, package siunitx offers lots of options to format the number. By default, leading zeros are removed:
documentclassarticle
usepackagesiunitx
begindocument
num000123; num-000456
enddocument
Result: 123; -456
add a comment |
number
See egreg's comment, for the simplest solution for integer numbers in the range -2147483647 to 2147483647:
number000123⌴
number-000456⌴
Result: 123 and -456
The space, marked with ⌴ ends the parsing of the number and prevents accident if digits are following in the normal text.
This solution is expandable and can be used inside csname, label, typeout, for example.
Package bigintcalc
This package provides an expandable method for removing leading zeros from integer numbers that are arbitrary large. From the documentation:
bigintcalcNum ⟨x⟩
Macro
bigintcalcNumconverts its argument to a normalized integer
number without unnecessary leading zeros or signs. The result matches
the regular expression:0|-?[1-9][0-9]*
Example:
usepackagebigintcalc% plain TeX: input bigintcalc.sty
...
bigintcalcNum000123456789123456789123456789
bigintcalcNum-000123456789123456789123456789
Result: 123456789123456789123456789 and -123456789123456789123456789
The macro is expandable, the package can be used with lots of TeX flavors (LaTeX, plain TeX, iniTeX, ...)
Package siunitx
If the number is to be intended to be printed, package siunitx offers lots of options to format the number. By default, leading zeros are removed:
documentclassarticle
usepackagesiunitx
begindocument
num000123; num-000456
enddocument
Result: 123; -456
add a comment |
number
See egreg's comment, for the simplest solution for integer numbers in the range -2147483647 to 2147483647:
number000123⌴
number-000456⌴
Result: 123 and -456
The space, marked with ⌴ ends the parsing of the number and prevents accident if digits are following in the normal text.
This solution is expandable and can be used inside csname, label, typeout, for example.
Package bigintcalc
This package provides an expandable method for removing leading zeros from integer numbers that are arbitrary large. From the documentation:
bigintcalcNum ⟨x⟩
Macro
bigintcalcNumconverts its argument to a normalized integer
number without unnecessary leading zeros or signs. The result matches
the regular expression:0|-?[1-9][0-9]*
Example:
usepackagebigintcalc% plain TeX: input bigintcalc.sty
...
bigintcalcNum000123456789123456789123456789
bigintcalcNum-000123456789123456789123456789
Result: 123456789123456789123456789 and -123456789123456789123456789
The macro is expandable, the package can be used with lots of TeX flavors (LaTeX, plain TeX, iniTeX, ...)
Package siunitx
If the number is to be intended to be printed, package siunitx offers lots of options to format the number. By default, leading zeros are removed:
documentclassarticle
usepackagesiunitx
begindocument
num000123; num-000456
enddocument
Result: 123; -456
number
See egreg's comment, for the simplest solution for integer numbers in the range -2147483647 to 2147483647:
number000123⌴
number-000456⌴
Result: 123 and -456
The space, marked with ⌴ ends the parsing of the number and prevents accident if digits are following in the normal text.
This solution is expandable and can be used inside csname, label, typeout, for example.
Package bigintcalc
This package provides an expandable method for removing leading zeros from integer numbers that are arbitrary large. From the documentation:
bigintcalcNum ⟨x⟩
Macro
bigintcalcNumconverts its argument to a normalized integer
number without unnecessary leading zeros or signs. The result matches
the regular expression:0|-?[1-9][0-9]*
Example:
usepackagebigintcalc% plain TeX: input bigintcalc.sty
...
bigintcalcNum000123456789123456789123456789
bigintcalcNum-000123456789123456789123456789
Result: 123456789123456789123456789 and -123456789123456789123456789
The macro is expandable, the package can be used with lots of TeX flavors (LaTeX, plain TeX, iniTeX, ...)
Package siunitx
If the number is to be intended to be printed, package siunitx offers lots of options to format the number. By default, leading zeros are removed:
documentclassarticle
usepackagesiunitx
begindocument
num000123; num-000456
enddocument
Result: 123; -456
answered 11 hours ago
Heiko OberdiekHeiko Oberdiek
234k19 gold badges574 silver badges926 bronze badges
234k19 gold badges574 silver badges926 bronze badges
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%2f502670%2fhow-to-get-rid-of-leading-zeros-in-a-number%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
1
number0000123will print123(notice the trailing space).– egreg
12 hours ago