Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using box dimensions in fp expressions #83

Closed
blefloch opened this issue Jul 14, 2012 · 3 comments
Closed

Using box dimensions in fp expressions #83

blefloch opened this issue Jul 14, 2012 · 3 comments
Assignees
Labels
enhancement New feature or request l3fp

Comments

@blefloch
Copy link
Member

Box dimensions can be used directly in dimension expressions but not floating point expressions.

\hbox_set:Nn \l_tmpa_box { abc }
\dim_show:n { \box_wd:N \l_tmpa_box }
\fp_show:n { \box_wd:N \l_tmpa_box }
@blefloch
Copy link
Member Author

In particular, this issue forbids the \Height, \Depth, \Width, and \TotalHeight design-level shorthands in xcoffins to possibly work in a floating point expression. The reason l3fp doesn't just apply \tex_the:D blindly is that 2.5 \c_zero_dim should not be unpacked to 2.50pt but to 2.5*0pt.

This means that we should only apply \tex_the:D when l3fp starts reading a number (perhaps also just after e). If we decide to do that, 2 \c_two 3 would give 2 * 23, which is a bit odd, but unavoidable.

@ghost ghost assigned blefloch Aug 1, 2012
@josephwright
Copy link
Member

Fix at the coffin level

@josephwright
Copy link
Member

@blefloch Seems to me there are two slightly different issues here. If you look at xcoffins we have

\cs_new_protected:Npn \@@_design_names:N #1
  {
    \dim_set:Nn \l_@@_height_dim { \coffin_ht:N #1 }
    \dim_set:Nn \l_@@_depth_dim  { \coffin_dp:N #1 }
    \dim_set:Nn \l_@@_width_dim  { \coffin_wd:N #1 }
    \dim_set:Nn \l_@@_totalheight_dim
      { \l_@@_height_dim + \l_@@_depth_dim }
    \cs_set_eq:NN \Height \l_@@_height_dim
    \cs_set_eq:NN \Depth \l_@@_depth_dim
    \cs_set_eq:NN \Width \l_@@_width_dim
    \cs_set_eq:NN \TotalHeight \l_@@_totalheight_dim
  }

which means \Height, etc. is not the same as \coffin_ht:N <name>. So the first question is is it that right (I'd say yes: this works nicely) and the second is do we see a need to alter \box_wd:N (#227).

As an artificial example that \Height etc. do work

\documentclass{article}
\usepackage{expl3}
\usepackage{xcoffins}
\NewCoffin\CoffinA
\begin{document}

\SetHorizontalCoffin\CoffinA{\rule{10pt}{10pt}}
\ExplSyntaxOn
\SetHorizontalPole\CoffinA{a}
  {\fp_to_dim:n{0.666\Width}}
\ShowCoffinStructure\CoffinA

\end{document}

gives

Size of coffin \CoffinA:
> ht = 10.0pt
> dp = 0.0pt
> wd = 10.0pt
Poles of coffin \CoffinA:
>  l  =>  {0pt}{0pt}{0pt}{1000pt}
>  hc  =>  {5.0pt}{0pt}{0pt}{1000pt}
>  r  =>  {10.0pt}{0pt}{0pt}{1000pt}
>  b  =>  {0pt}{0.0pt}{1000pt}{0pt}
>  vc  =>  {0pt}{5.0pt}{1000pt}{0pt}
>  t  =>  {0pt}{10.0pt}{1000pt}{0pt}
>  B  =>  {0pt}{0pt}{1000pt}{0pt}
>  H  =>  {0pt}{0pt}{1000pt}{0pt}
>  T  =>  {0pt}{0pt}{1000pt}{0pt}
>  a  =>  {0pt}{6.66pt}{1000pt}{0pt}.
<recently read> }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request l3fp
Projects
None yet
Development

No branches or pull requests

2 participants