Does expl3 have alternative to settowidth and settoheight?Is there a gentle introduction to learning expl3 syntaxEmulating @ifnextchar in expl3expl3 code with tabularxDoes expl3 have arrays?Access xparse's BooleanTrue via latex3 expl3Does expl3 key-setting syntax have an equivalent of TikZ/PGF's .cd?expl3 function not expanded inside `label…`Determining the length of an expl3 sequenceHow to test a newif conditional in expl3Locally redefining ~ in code that uses expl3 facilities
How do I get a cleat that's stuck in a pedal, detached from the shoe, out?
Is American Express widely accepted in France?
What if you don't bring your credit card or debit for incidentals?
Pros and cons of writing a book review?
Why is Colorado so different politically from nearby states?
Could a guilty Boris Johnson be used to cancel Brexit?
How to detach yourself from a character you're going to kill?
What is a simple, physical situation where complex numbers emerge naturally?
Why were the Night's Watch required to be celibate?
Should this code fail to compile in C++17?
Strange math syntax in old basic listing
What is the right way to float a home lab?
How can I grammatically understand "Wir über uns"?
What does it mean by "d-ism of Leibniz" and "dotage of Newton" in simple English?
The deliberate use of misleading terminology
Asking for something with different prices
What caused the tendency for conservatives to not support climate change regulations?
What is the intuition behind uniform continuity?
What does the behaviour of water on the skin of an aircraft in flight tell us?
What should I do about a religious player who refuses to accept the existence of multiple gods in D&D?
How do I truncate a csv file?
Can an old DSLR be upgraded to match modern smartphone image quality
If a massive object like Jupiter flew past the Earth how close would it need to come to pull people off of the surface?
Accidentally cashed a check twice
Does expl3 have alternative to settowidth and settoheight?
Is there a gentle introduction to learning expl3 syntaxEmulating @ifnextchar in expl3expl3 code with tabularxDoes expl3 have arrays?Access xparse's BooleanTrue via latex3 expl3Does expl3 key-setting syntax have an equivalent of TikZ/PGF's .cd?expl3 function not expanded inside `label…`Determining the length of an expl3 sequenceHow to test a newif conditional in expl3Locally redefining ~ in code that uses expl3 facilities
How can I substitute following code with expl3
interfaces (that do the same job)?
documentclass[varwidth]standalone
begindocument
newlengthspaceWidth
settowidthspaceWidth
thespaceWidth
enddocument
expl3 latex3 lengths
add a comment |
How can I substitute following code with expl3
interfaces (that do the same job)?
documentclass[varwidth]standalone
begindocument
newlengthspaceWidth
settowidthspaceWidth
thespaceWidth
enddocument
expl3 latex3 lengths
1
your question title is about measuring boxes but if your actual goal is the example in the code then this is a very inefficient way to find the width of a space, that width is already available as a tex length it is fontdimen 2 of the current font.
– David Carlisle
May 24 at 6:45
add a comment |
How can I substitute following code with expl3
interfaces (that do the same job)?
documentclass[varwidth]standalone
begindocument
newlengthspaceWidth
settowidthspaceWidth
thespaceWidth
enddocument
expl3 latex3 lengths
How can I substitute following code with expl3
interfaces (that do the same job)?
documentclass[varwidth]standalone
begindocument
newlengthspaceWidth
settowidthspaceWidth
thespaceWidth
enddocument
expl3 latex3 lengths
expl3 latex3 lengths
asked May 23 at 23:50
bp2017bp2017
1,234316
1,234316
1
your question title is about measuring boxes but if your actual goal is the example in the code then this is a very inefficient way to find the width of a space, that width is already available as a tex length it is fontdimen 2 of the current font.
– David Carlisle
May 24 at 6:45
add a comment |
1
your question title is about measuring boxes but if your actual goal is the example in the code then this is a very inefficient way to find the width of a space, that width is already available as a tex length it is fontdimen 2 of the current font.
– David Carlisle
May 24 at 6:45
1
1
your question title is about measuring boxes but if your actual goal is the example in the code then this is a very inefficient way to find the width of a space, that width is already available as a tex length it is fontdimen 2 of the current font.
– David Carlisle
May 24 at 6:45
your question title is about measuring boxes but if your actual goal is the example in the code then this is a very inefficient way to find the width of a space, that width is already available as a tex length it is fontdimen 2 of the current font.
– David Carlisle
May 24 at 6:45
add a comment |
2 Answers
2
active
oldest
votes
There is nothing equivalent (that I know of), but you can implement your own (and by implement I mean copy from latex.ltx
and change the syntax). I defined SetToHeight
, SetToWidth
, and SetToDepth
, that do the same as the LaTeX2e's variants.
However, for the specific case of a space, you can use fontdimen2font
, which will get the width of a space in the current font without the need to measure a box, thus it is expandable, so you can use in dimension expressions. I defined an expl3
y wrapper for that as well:
documentclass[varwidth]standalone
usepackageexpl3
ExplSyntaxOn
box_new:N l_bp_set_to_box
cs_new_protected:Npn bp_box_set_to:NNn #1 #2 #3
hbox_set:Nn l_bp_set_to_box #3
dim_set:Nn #2 #1 l_bp_set_to_box
box_set_eq:NN l_bp_set_to_box c_empty_box
cs_new_protected:Npn bp_set_to_height:Nn bp_box_set_to:NNn box_ht:N
cs_new_protected:Npn bp_set_to_depth:Nn bp_box_set_to:NNn box_dp:N
cs_new_protected:Npn bp_set_to_width:Nn bp_box_set_to:NNn box_wd:N
% Expandable width of a space:
cs_new:Npn WidthOfSpace tex_fontdimen:D 2 tex_font:D
ExplSyntaxOff
begindocument
ExplSyntaxOn
dim_new:N spaceWidth
bp_set_to_width:Nn spaceWidth
dim_use:N spaceWidth
par
dim_use:N WidthOfSpace
ExplSyntaxOff
enddocument
Output:
Why__
? These would need to be public
– Joseph Wright♦
May 24 at 6:06
1
I wouldn't usel_tmpa_box
.
– egreg
May 24 at 6:24
@JosephWright Only theSetToSomething
, no? Why does__bp_box_set_to:NNn
need to be public?
– Phelype Oleinik
May 24 at 9:00
@PhelypeOleinik Because of the document/code level split: all document commands should be defined in terms of documented code-level ones.
– Joseph Wright♦
May 24 at 9:13
1
@PhelypeOleinik Model is: document command defines user interface, this is implemented by code-level commands which startmodule_...
(so should be documented), and then they can use__module...
commands which are internal and thus 'no use'.
– Joseph Wright♦
May 24 at 9:20
|
show 1 more comment
coffin_new:NspaceCoffin
hcoffin_set:NnspaceCoffin
% space width
dim_eval:ncoffin_wd:NspaceCoffin
box_new:NspaceBox
hbox_set:NnspaceBox
% space width
dim_eval:nbox_wd:NspaceBox
2
You can, sure, use a coffin, however the computational overhead is much larger than for a simple box (as you edited in just now :-)
– Phelype Oleinik
May 24 at 0:23
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%2f492367%2fdoes-expl3-have-alternative-to-settowidth-and-settoheight%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
There is nothing equivalent (that I know of), but you can implement your own (and by implement I mean copy from latex.ltx
and change the syntax). I defined SetToHeight
, SetToWidth
, and SetToDepth
, that do the same as the LaTeX2e's variants.
However, for the specific case of a space, you can use fontdimen2font
, which will get the width of a space in the current font without the need to measure a box, thus it is expandable, so you can use in dimension expressions. I defined an expl3
y wrapper for that as well:
documentclass[varwidth]standalone
usepackageexpl3
ExplSyntaxOn
box_new:N l_bp_set_to_box
cs_new_protected:Npn bp_box_set_to:NNn #1 #2 #3
hbox_set:Nn l_bp_set_to_box #3
dim_set:Nn #2 #1 l_bp_set_to_box
box_set_eq:NN l_bp_set_to_box c_empty_box
cs_new_protected:Npn bp_set_to_height:Nn bp_box_set_to:NNn box_ht:N
cs_new_protected:Npn bp_set_to_depth:Nn bp_box_set_to:NNn box_dp:N
cs_new_protected:Npn bp_set_to_width:Nn bp_box_set_to:NNn box_wd:N
% Expandable width of a space:
cs_new:Npn WidthOfSpace tex_fontdimen:D 2 tex_font:D
ExplSyntaxOff
begindocument
ExplSyntaxOn
dim_new:N spaceWidth
bp_set_to_width:Nn spaceWidth
dim_use:N spaceWidth
par
dim_use:N WidthOfSpace
ExplSyntaxOff
enddocument
Output:
Why__
? These would need to be public
– Joseph Wright♦
May 24 at 6:06
1
I wouldn't usel_tmpa_box
.
– egreg
May 24 at 6:24
@JosephWright Only theSetToSomething
, no? Why does__bp_box_set_to:NNn
need to be public?
– Phelype Oleinik
May 24 at 9:00
@PhelypeOleinik Because of the document/code level split: all document commands should be defined in terms of documented code-level ones.
– Joseph Wright♦
May 24 at 9:13
1
@PhelypeOleinik Model is: document command defines user interface, this is implemented by code-level commands which startmodule_...
(so should be documented), and then they can use__module...
commands which are internal and thus 'no use'.
– Joseph Wright♦
May 24 at 9:20
|
show 1 more comment
There is nothing equivalent (that I know of), but you can implement your own (and by implement I mean copy from latex.ltx
and change the syntax). I defined SetToHeight
, SetToWidth
, and SetToDepth
, that do the same as the LaTeX2e's variants.
However, for the specific case of a space, you can use fontdimen2font
, which will get the width of a space in the current font without the need to measure a box, thus it is expandable, so you can use in dimension expressions. I defined an expl3
y wrapper for that as well:
documentclass[varwidth]standalone
usepackageexpl3
ExplSyntaxOn
box_new:N l_bp_set_to_box
cs_new_protected:Npn bp_box_set_to:NNn #1 #2 #3
hbox_set:Nn l_bp_set_to_box #3
dim_set:Nn #2 #1 l_bp_set_to_box
box_set_eq:NN l_bp_set_to_box c_empty_box
cs_new_protected:Npn bp_set_to_height:Nn bp_box_set_to:NNn box_ht:N
cs_new_protected:Npn bp_set_to_depth:Nn bp_box_set_to:NNn box_dp:N
cs_new_protected:Npn bp_set_to_width:Nn bp_box_set_to:NNn box_wd:N
% Expandable width of a space:
cs_new:Npn WidthOfSpace tex_fontdimen:D 2 tex_font:D
ExplSyntaxOff
begindocument
ExplSyntaxOn
dim_new:N spaceWidth
bp_set_to_width:Nn spaceWidth
dim_use:N spaceWidth
par
dim_use:N WidthOfSpace
ExplSyntaxOff
enddocument
Output:
Why__
? These would need to be public
– Joseph Wright♦
May 24 at 6:06
1
I wouldn't usel_tmpa_box
.
– egreg
May 24 at 6:24
@JosephWright Only theSetToSomething
, no? Why does__bp_box_set_to:NNn
need to be public?
– Phelype Oleinik
May 24 at 9:00
@PhelypeOleinik Because of the document/code level split: all document commands should be defined in terms of documented code-level ones.
– Joseph Wright♦
May 24 at 9:13
1
@PhelypeOleinik Model is: document command defines user interface, this is implemented by code-level commands which startmodule_...
(so should be documented), and then they can use__module...
commands which are internal and thus 'no use'.
– Joseph Wright♦
May 24 at 9:20
|
show 1 more comment
There is nothing equivalent (that I know of), but you can implement your own (and by implement I mean copy from latex.ltx
and change the syntax). I defined SetToHeight
, SetToWidth
, and SetToDepth
, that do the same as the LaTeX2e's variants.
However, for the specific case of a space, you can use fontdimen2font
, which will get the width of a space in the current font without the need to measure a box, thus it is expandable, so you can use in dimension expressions. I defined an expl3
y wrapper for that as well:
documentclass[varwidth]standalone
usepackageexpl3
ExplSyntaxOn
box_new:N l_bp_set_to_box
cs_new_protected:Npn bp_box_set_to:NNn #1 #2 #3
hbox_set:Nn l_bp_set_to_box #3
dim_set:Nn #2 #1 l_bp_set_to_box
box_set_eq:NN l_bp_set_to_box c_empty_box
cs_new_protected:Npn bp_set_to_height:Nn bp_box_set_to:NNn box_ht:N
cs_new_protected:Npn bp_set_to_depth:Nn bp_box_set_to:NNn box_dp:N
cs_new_protected:Npn bp_set_to_width:Nn bp_box_set_to:NNn box_wd:N
% Expandable width of a space:
cs_new:Npn WidthOfSpace tex_fontdimen:D 2 tex_font:D
ExplSyntaxOff
begindocument
ExplSyntaxOn
dim_new:N spaceWidth
bp_set_to_width:Nn spaceWidth
dim_use:N spaceWidth
par
dim_use:N WidthOfSpace
ExplSyntaxOff
enddocument
Output:
There is nothing equivalent (that I know of), but you can implement your own (and by implement I mean copy from latex.ltx
and change the syntax). I defined SetToHeight
, SetToWidth
, and SetToDepth
, that do the same as the LaTeX2e's variants.
However, for the specific case of a space, you can use fontdimen2font
, which will get the width of a space in the current font without the need to measure a box, thus it is expandable, so you can use in dimension expressions. I defined an expl3
y wrapper for that as well:
documentclass[varwidth]standalone
usepackageexpl3
ExplSyntaxOn
box_new:N l_bp_set_to_box
cs_new_protected:Npn bp_box_set_to:NNn #1 #2 #3
hbox_set:Nn l_bp_set_to_box #3
dim_set:Nn #2 #1 l_bp_set_to_box
box_set_eq:NN l_bp_set_to_box c_empty_box
cs_new_protected:Npn bp_set_to_height:Nn bp_box_set_to:NNn box_ht:N
cs_new_protected:Npn bp_set_to_depth:Nn bp_box_set_to:NNn box_dp:N
cs_new_protected:Npn bp_set_to_width:Nn bp_box_set_to:NNn box_wd:N
% Expandable width of a space:
cs_new:Npn WidthOfSpace tex_fontdimen:D 2 tex_font:D
ExplSyntaxOff
begindocument
ExplSyntaxOn
dim_new:N spaceWidth
bp_set_to_width:Nn spaceWidth
dim_use:N spaceWidth
par
dim_use:N WidthOfSpace
ExplSyntaxOff
enddocument
Output:
edited May 24 at 9:32
answered May 24 at 0:18
Phelype OleinikPhelype Oleinik
28.6k64894
28.6k64894
Why__
? These would need to be public
– Joseph Wright♦
May 24 at 6:06
1
I wouldn't usel_tmpa_box
.
– egreg
May 24 at 6:24
@JosephWright Only theSetToSomething
, no? Why does__bp_box_set_to:NNn
need to be public?
– Phelype Oleinik
May 24 at 9:00
@PhelypeOleinik Because of the document/code level split: all document commands should be defined in terms of documented code-level ones.
– Joseph Wright♦
May 24 at 9:13
1
@PhelypeOleinik Model is: document command defines user interface, this is implemented by code-level commands which startmodule_...
(so should be documented), and then they can use__module...
commands which are internal and thus 'no use'.
– Joseph Wright♦
May 24 at 9:20
|
show 1 more comment
Why__
? These would need to be public
– Joseph Wright♦
May 24 at 6:06
1
I wouldn't usel_tmpa_box
.
– egreg
May 24 at 6:24
@JosephWright Only theSetToSomething
, no? Why does__bp_box_set_to:NNn
need to be public?
– Phelype Oleinik
May 24 at 9:00
@PhelypeOleinik Because of the document/code level split: all document commands should be defined in terms of documented code-level ones.
– Joseph Wright♦
May 24 at 9:13
1
@PhelypeOleinik Model is: document command defines user interface, this is implemented by code-level commands which startmodule_...
(so should be documented), and then they can use__module...
commands which are internal and thus 'no use'.
– Joseph Wright♦
May 24 at 9:20
Why
__
? These would need to be public– Joseph Wright♦
May 24 at 6:06
Why
__
? These would need to be public– Joseph Wright♦
May 24 at 6:06
1
1
I wouldn't use
l_tmpa_box
.– egreg
May 24 at 6:24
I wouldn't use
l_tmpa_box
.– egreg
May 24 at 6:24
@JosephWright Only the
SetToSomething
, no? Why does __bp_box_set_to:NNn
need to be public?– Phelype Oleinik
May 24 at 9:00
@JosephWright Only the
SetToSomething
, no? Why does __bp_box_set_to:NNn
need to be public?– Phelype Oleinik
May 24 at 9:00
@PhelypeOleinik Because of the document/code level split: all document commands should be defined in terms of documented code-level ones.
– Joseph Wright♦
May 24 at 9:13
@PhelypeOleinik Because of the document/code level split: all document commands should be defined in terms of documented code-level ones.
– Joseph Wright♦
May 24 at 9:13
1
1
@PhelypeOleinik Model is: document command defines user interface, this is implemented by code-level commands which start
module_...
(so should be documented), and then they can use __module...
commands which are internal and thus 'no use'.– Joseph Wright♦
May 24 at 9:20
@PhelypeOleinik Model is: document command defines user interface, this is implemented by code-level commands which start
module_...
(so should be documented), and then they can use __module...
commands which are internal and thus 'no use'.– Joseph Wright♦
May 24 at 9:20
|
show 1 more comment
coffin_new:NspaceCoffin
hcoffin_set:NnspaceCoffin
% space width
dim_eval:ncoffin_wd:NspaceCoffin
box_new:NspaceBox
hbox_set:NnspaceBox
% space width
dim_eval:nbox_wd:NspaceBox
2
You can, sure, use a coffin, however the computational overhead is much larger than for a simple box (as you edited in just now :-)
– Phelype Oleinik
May 24 at 0:23
add a comment |
coffin_new:NspaceCoffin
hcoffin_set:NnspaceCoffin
% space width
dim_eval:ncoffin_wd:NspaceCoffin
box_new:NspaceBox
hbox_set:NnspaceBox
% space width
dim_eval:nbox_wd:NspaceBox
2
You can, sure, use a coffin, however the computational overhead is much larger than for a simple box (as you edited in just now :-)
– Phelype Oleinik
May 24 at 0:23
add a comment |
coffin_new:NspaceCoffin
hcoffin_set:NnspaceCoffin
% space width
dim_eval:ncoffin_wd:NspaceCoffin
box_new:NspaceBox
hbox_set:NnspaceBox
% space width
dim_eval:nbox_wd:NspaceBox
coffin_new:NspaceCoffin
hcoffin_set:NnspaceCoffin
% space width
dim_eval:ncoffin_wd:NspaceCoffin
box_new:NspaceBox
hbox_set:NnspaceBox
% space width
dim_eval:nbox_wd:NspaceBox
edited May 24 at 0:22
answered May 24 at 0:13
bp2017bp2017
1,234316
1,234316
2
You can, sure, use a coffin, however the computational overhead is much larger than for a simple box (as you edited in just now :-)
– Phelype Oleinik
May 24 at 0:23
add a comment |
2
You can, sure, use a coffin, however the computational overhead is much larger than for a simple box (as you edited in just now :-)
– Phelype Oleinik
May 24 at 0:23
2
2
You can, sure, use a coffin, however the computational overhead is much larger than for a simple box (as you edited in just now :-)
– Phelype Oleinik
May 24 at 0:23
You can, sure, use a coffin, however the computational overhead is much larger than for a simple box (as you edited in just now :-)
– Phelype Oleinik
May 24 at 0:23
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%2f492367%2fdoes-expl3-have-alternative-to-settowidth-and-settoheight%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
your question title is about measuring boxes but if your actual goal is the example in the code then this is a very inefficient way to find the width of a space, that width is already available as a tex length it is fontdimen 2 of the current font.
– David Carlisle
May 24 at 6:45