如何拉伸横向长度

如何拉伸横向长度

在此丹尼尔·伯恩斯坦使用水平拉伸的线条看到这个(第 7 页)。我也在尝试这样做。我看到问题,但没有一个答案能够产生预期的结果。有人能帮忙吗?

答案1

这是使用 LaTeX3 函数的实现。我还添加了更简单的十六进制输入情况。

\documentclass{article}
\usepackage{amsmath,xparse}
\newcommand\op[1]{\operatorname{#1}}
\newcommand\he[1]{\mathtt{0x#1}}

\ExplSyntaxOn
\NewDocumentCommand{\fl}{m}
 {
  \pushpen_fl:n { #1 }
 }

\dim_new:N \l_pushpen_digit_dim
\seq_new:N \l_pushpen_input_seq
\seq_new:N \l_pushpen_output_seq

\cs_new_protected:Npn \pushpen_fl:n #1
 {
  \hbox_set:Nn \l_tmpa_box { 0 }
  \dim_set:Nn \l_pushpen_digit_dim { 3\box_wd:N \l_tmpa_box }
  \seq_set_split:Nnn \l_pushpen_input_seq { , } { #1 }
  \seq_clear:N \l_pushpen_output_seq
  \seq_map_inline:Nn \l_pushpen_input_seq
   {
    \seq_put_right:Nn \l_pushpen_output_seq { \makebox[\l_pushpen_digit_dim][r]{##1} }
   }
  \seq_use:Nn \l_pushpen_output_seq { , }
 }
\ExplSyntaxOff

\begin{document}
\begin{align*}
\op{doubleround}(
&\he{00000001}, \he{00000000}, \he{00000000}, \he{00000000},\\
&\he{00000000}, \he{00000000}, \he{00000000}, \he{00000000},\\
&\he{00000000}, \he{00000000}, \he{00000000}, \he{00000000},\\
&\he{00000000}, \he{00000000}, \he{00000000}, \he{00000000})\\
=(
&\he{8186a22d}, \he{0040a284}, \he{82479210}, \he{06929051},\\
&\he{08000090}, \he{02402200}, \he{00004000}, \he{00800000},\\
&\he{00010200}, \he{20400000}, \he{08008104}, \he{00000000},\\
&\he{20500000}, \he{a0000040}, \he{0008180a}, \he{612a8020}).\\
\op{doubleround}(
&\he{de501066}, \he{6f9eb8f7}, \he{e4fbbd9b}, \he{454e3f57},\\
&\he{b75540d3}, \he{43e93a4c}, \he{3a6f2aa0}, \he{726d6b36},\\
&\he{9243f484}, \he{9145d1e8}, \he{4fa9d247}, \he{dc8dee11},\\
&\he{054bf545}, \he{254dd653}, \he{d9421b6d}, \he{67b276c1})\\
=(
&\he{ccaaf672}, \he{23d960f7}, \he{9153e63a}, \he{cd9a60d0},\\
&\he{50440492}, \he{f07cad19}, \he{ae344aa0}, \he{df4cfdfc},\\
&\he{ca531c29}, \he{8e7943db}, \he{ac1680cd}, \he{d503ca00},\\
&\he{a74b2ad6}, \he{bc331c5c}, \he{1dda24c7}, \he{ee928277}).
\end{align*}
Another example with decimal digits:
\begin{align*}
\op{Salsa20}(
&\fl{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},\\
&\fl{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},\\
&\fl{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},\\
&\fl{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})\\
=(
&\fl{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},\\
&\fl{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},\\
&\fl{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},\\
&\fl{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}).\\
\op{Salsa20}(
&\fl{211,159, 13,115, 76, 55, 82,183,  3,117,222, 37,191,187,234,136},\\
&\fl{ 49,237,179, 48,  1,106,178,219,175,199,166, 48, 86, 16,179,207},\\
&\fl{ 31,240, 32, 63, 15, 83, 93,161,116,147, 48,113,238, 55,204, 36},\\
&\fl{ 79,201,235, 79,  3, 81,156, 47,203, 26,244,243, 88,118,104, 54})\\
=(
&\fl{109, 42,178,168,156,240,248,238,168,196,190,203, 26,110,170,154},\\
&\fl{ 29, 29,150, 26,150, 30,235,249,190,163,251, 48, 69,144, 51, 57},\\
&\fl{118, 40,152,157,180, 57, 27, 94,107, 42,236, 35, 27,111,114,114},\\
&\fl{219,236,232,135,111,155,110, 18, 24,232, 95,158,179, 19, 48,202}).
\end{align*}

\end{document}

在此处输入图片描述

用于输入值的简化语法的版本;类似的想法可用于十六进制输出。

\documentclass{article}
\usepackage{amsmath,xparse}
\newcommand\op[1]{\operatorname{#1}}

\ExplSyntaxOn
\NewDocumentCommand{\fl}{m}
 {
  \pushpen_fl:n { #1 }
 }

\dim_new:N \g_pushpen_digit_dim
\seq_new:N \l_pushpen_input_seq
\seq_new:N \l_pushpen_output_seq
\int_new:N \l_pushpen_step_int

\cs_new_protected:Npn \pushpen_fl:n #1
 {
  \hbox_set:Nn \l_tmpa_box { 0 }
  \dim_gset:Nn \g_pushpen_digit_dim { 3\box_wd:N \l_tmpa_box }
  \int_zero:N \l_pushpen_step_int
  \seq_set_split:Nnn \l_pushpen_input_seq { , } { #1 }
  \seq_clear:N \l_pushpen_output_seq
  \seq_put_right:Nn \l_pushpen_output_seq { ( & } % initialize
  \seq_map_inline:Nn \l_pushpen_input_seq
   {
    \int_incr:N \l_pushpen_step_int
    \seq_put_right:Nn \l_pushpen_output_seq { \makebox[\g_pushpen_digit_dim][r]{##1} }
    \int_compare:nTF { \l_pushpen_step_int == 64 } % we're doing the last item
     {
      \seq_put_right:Nn \l_pushpen_output_seq { ) }
     }
     {
      \int_compare:nTF { \int_mod:nn { \l_pushpen_step_int } { 16 } == 0 } % end of row
       {
        \seq_put_right:Nn \l_pushpen_output_seq { , \\ & }
       }
       {
        \seq_put_right:Nn \l_pushpen_output_seq { , }
       }
     }
   }
  \seq_use:Nn \l_pushpen_output_seq { }
 }
\ExplSyntaxOff

\begin{document}
\begin{align*}
\op{Salsa20}
\fl{
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}\\
=
\fl{
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}.\\
\op{Salsa20}
\fl{
  211,159, 13,115, 76, 55, 82,183,  3,117,222, 37,191,187,234,136,
   49,237,179, 48,  1,106,178,219,175,199,166, 48, 86, 16,179,207,
   31,240, 32, 63, 15, 83, 93,161,116,147, 48,113,238, 55,204, 36,
   79,201,235, 79,  3, 81,156, 47,203, 26,244,243, 88,118,104, 54
}\\
=
\fl{
  109, 42,178,168,156,240,248,238,168,196,190,203, 26,110,170,154,
   29, 29,150, 26,150, 30,235,249,190,163,251, 48, 69,144, 51, 57,
  118, 40,152,157,180, 57, 27, 94,107, 42,236, 35, 27,111,114,114,
  219,236,232,135,111,155,110, 18, 24,232, 95,158,179, 19, 48,202
}.
\end{align*}

\end{document}

在此处输入图片描述

答案2

对于array倾向于此的人来说,这是一个常规的实现:

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath,array}% http://ctan.org/pkg/{amsmath,array}
\begin{document}
\[
  \settowidth{\dimen0}{$000$}% Capture widest element
  \begin{array}{r@{}*{15}{>{\raggedleft}p{\dimen0}@{,{} }}>{\raggedleft\arraybackslash}p{\dimen0}@{}l}
    \text{Salsa20}(&   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 & , \\
                   &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 & , \\
                   &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 & , \\
                   &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 & ) \\
               {}=(&   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 & , \\
                   &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 & , \\
                   &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 & , \\
                   &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 &   0 & ). \\
    \text{Salsa20}(& 211 & 159 &  13 & 115 &  76 &  55 &  82 & 183 &   3 & 117 & 222 &  37 & 191 & 187 & 234 & 136 & , \\
                   &  49 & 237 & 179 &  48 &   1 & 106 & 178 & 219 & 175 & 199 & 166 &  48 &  86 &  16 & 179 & 207 & , \\
                   &  31 & 240 &  32 &  63 &  15 &  83 &  93 & 161 & 116 & 147 &  48 & 113 & 238 &  55 & 204 &  36 & , \\
                   &  79 & 201 & 235 &  79 &   3 &  81 & 156 &  47 & 203 &  26 & 244 & 243 &  88 & 118 & 104 &  54 & ) \\
               {}=(& 109 &  42 & 178 & 168 & 156 & 240 & 248 & 238 & 168 & 196 & 190 & 203 &  26 & 110 & 170 & 154 & , \\
                   &  29 &  29 & 150 &  26 & 150 &  30 & 235 & 249 & 190 & 163 & 251 &  48 &  69 & 144 &  51 &  57 & , \\
                   & 118 &  40 & 152 & 157 & 180 &  57 &  27 &  94 & 107 &  42 & 236 &  35 &  27 & 111 & 114 & 114 & , \\
                   & 219 & 236 & 232 & 135 & 111 & 155 & 110 &  18 &  24 & 232 &  95 & 158 & 179 &  19 &  48 & 202 & ).
  \end{array}
\]
\end{document}

array用于单元格内的右对齐,而amsmath提供\text

答案3

这是使用正在开发的tabstackengine包,首先在这里介绍根据最宽的列编写具有等间距列的表格(源代码可从测量对齐)。

该计划扩展了stackengine通过添加制表功能扩展了该包。这个答案,我可以在对齐环境内进行制表吗?,给出了该包的一些语法。我很抱歉,我没有完成该包并将其发布出去,因此查看其实际运行情况的唯一方法是通过此站点搜索tabstackengine


在这种情况下,带制表符的长下堆栈允许设置每列之间的均匀间隙,在这种情况下,我将制表符设置为 .5ex(“长”表示每行具有均匀的基线到基线间距,“下”表示整体基线设置在堆栈的顶行)。我确实需要几个\rlaps/ \phantoms 作为对右括号的更正,以及一个\phantom用于加宽只有 2 位数据的列。

\documentclass{article}
\usepackage{tabstackengine}
\textwidth 6.5in
\begin{document}
\setstacktabbedgap{.5ex}
\noindent Salsa20
\tabbedLongunderstack[r]{
(211;&159;& 13;&115;& \protect\phantom{1}76;& 55;& 82;&183;& 3;&117;&222;& 37;&191;&187;&234;&136;\\
49;&237;&179;& 48;& 1;&106;&178;&219;&175;&199;&166;& 48;& 86;& 16;&179;&207;\\
31;&240;& 32;& 63;& 15;& 83;& 93;&161;&116;&147;& 48;&113;&238;& 55;&204;& 36;\\
79;&201;&235;& 79;& 3;& 81;&156;& 47;&203;& 26;&244;&243;& 88;&118;&104;& 54\rlap{):}\protect\phantom{;}
}\\
\makebox[\widthof{Salsa20}][r]{=}
\tabbedLongunderstack[r]{
(109;& 42;&178;&168;&156;&240;&248;&238;&168;&196;&190;&203;& 26;&110;&170;&154;\\
29;& 29;&150;& 26;&150;& 30;&235;&249;&190;&163;&251;& 48;& 69;&144;& 51;& 57;\\
118;& 40;&152;&157;&180;& 57;& 27;& 94;&107;& 42;&236;& 35;& 27;&111;&114;&114;\\
219;&236;&232;&135;&111;&155;&110;& 18;& 24;&232;& 95;&158;&179;& 19;& 48;&202\rlap{):}\protect\phantom{;}
}
\end{document}

在此处输入图片描述

相关内容