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













3















How can I substitute following code with expl3 interfaces (that do the same job)?



documentclass[varwidth]standalone
begindocument
newlengthspaceWidth
settowidthspaceWidth
thespaceWidth
enddocument









share|improve this question

















  • 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















3















How can I substitute following code with expl3 interfaces (that do the same job)?



documentclass[varwidth]standalone
begindocument
newlengthspaceWidth
settowidthspaceWidth
thespaceWidth
enddocument









share|improve this question

















  • 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













3












3








3








How can I substitute following code with expl3 interfaces (that do the same job)?



documentclass[varwidth]standalone
begindocument
newlengthspaceWidth
settowidthspaceWidth
thespaceWidth
enddocument









share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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












  • 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










2 Answers
2






active

oldest

votes


















6














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 expl3y 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:




enter image description here







share|improve this answer

























  • Why __? These would need to be public

    – Joseph Wright
    May 24 at 6:06






  • 1





    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











  • @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 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


















2














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





share|improve this answer




















  • 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











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
);



);













draft saved

draft discarded


















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









6














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 expl3y 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:




enter image description here







share|improve this answer

























  • Why __? These would need to be public

    – Joseph Wright
    May 24 at 6:06






  • 1





    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











  • @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 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















6














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 expl3y 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:




enter image description here







share|improve this answer

























  • Why __? These would need to be public

    – Joseph Wright
    May 24 at 6:06






  • 1





    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











  • @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 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













6












6








6







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 expl3y 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:




enter image description here







share|improve this answer















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 expl3y 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:




enter image description here








share|improve this answer














share|improve this answer



share|improve this answer








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 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











  • @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 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

















  • Why __? These would need to be public

    – Joseph Wright
    May 24 at 6:06






  • 1





    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











  • @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 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
















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











2














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





share|improve this answer




















  • 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














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





share|improve this answer




















  • 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








2







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





share|improve this answer















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






share|improve this answer














share|improve this answer



share|improve this answer








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












  • 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

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?