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

jiazhu: 夹注的底线对齐 #535

Closed
tanukihee opened this issue Aug 18, 2020 · 2 comments · Fixed by #547
Closed

jiazhu: 夹注的底线对齐 #535

tanukihee opened this issue Aug 18, 2020 · 2 comments · Fixed by #547

Comments

@tanukihee
Copy link
Contributor

#508 中,夹注是中线对齐的,但在 clreq 的此份提案中,单行的夹注应该是底线对齐,希望能加一个选项,让用户自己决定是中线对齐还是底线对齐。

@tanukihee
Copy link
Contributor Author

tanukihee commented Aug 18, 2020

底线对齐的实现比较简单,夹注的基线下移量为 $s_o (1 - r_o) - s_i (1 - r_i)$,不需要考虑多行的情况,但括号的下移亦需更改。

效果图
image

\cs_new_protected:Npn \__jiazhu_calc_box_offset:
{
  \exp_args:Nxx \__jiazhu_calc_box_offset_aux:nn
  {
    \fp_compare:nNnTF \l__jiazhu_jzideoht_fp = \c_zero_fp
    { \fp_eval:n { 1 -   \l__jiazhu_ideoht_fp } }
    { \fp_eval:n { 1 - \l__jiazhu_jzideoht_fp } }
  }
  { \fp_eval:n { 1 - \l__jiazhu_ideoht_fp } }
}

\cs_new_protected:Npn \__jiazhu_calc_box_offset_aux:nn #1#2
{
  \dim_set:Nn \l__jiazhu_box_offset_dim
  {
    #2 \l__jiazhu_outer_unit_dim - #1 \l__jiazhu_unit_dim
  }
  \dim_set:Nn \l__jiazhu_mark_offset_dim
  {
    #2 \l__jiazhu_outer_unit_dim - \fp_eval:n { #1 * \l__jiazhu_bracket_ratio_fp } \l__jiazhu_unit_dim
  }
}

@tanukihee
Copy link
Contributor Author

我忘了考虑竖排情况了……竖排时单行夹注是右对齐,对应到横排应该是顶线对齐。此时夹注的基线下移量为 $r_i s_i + (n - 1) b - r_o s_o$,括号下移亦如此。

\cs_new_protected:Npn \__jiazhu_calc_box_offset:
{
  \exp_args:Nxx \__jiazhu_calc_box_offset_aux:nn
  {
    \fp_compare:nNnTF \l__jiazhu_jzideoht_fp = \c_zero_fp
    { \fp_eval:n { \l__jiazhu_ideoht_fp   } }
    { \fp_eval:n { \l__jiazhu_jzideoht_fp } }
  }
  { \fp_eval:n { \l__jiazhu_ideoht_fp } }
}

\cs_new_protected:Npn \__jiazhu_calc_box_offset_aux:nn #1#2
{
  \dim_set:Nn \l__jiazhu_box_offset_dim
  {
    #1 \l__jiazhu_unit_dim + \int_eval:n { \l__jiazhu_lines_int - 1 } \tex_baselineskip:D - #2 \l__jiazhu_outer_unit_dim
  }
  \dim_set:Nn \l__jiazhu_mark_offset_dim
  {
    \fp_eval:n { #1 * \l__jiazhu_bracket_ratio_fp } \l__jiazhu_unit_dim - #2 \l__jiazhu_outer_unit_dim
  }
}

效果图
image

感觉可以让 alignment 接受两个参数,分别控制夹注的两个对其方向(tmb/lcr)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants