答案1
使用 egreg 的答案,我只需更改一个命令即可获得第一级下划线下方的上划线 - 所以这里就是
\documentclass{article}
\ExplSyntaxOn
\NewDocumentCommand{\doubleunderline}{m}
{
\raisebox{-2pt}{\underline{#1}}
}
\NewDocumentCommand{\foo}{mmm}
{% #1 = string
% #2 = doubleunderlines
% #3 = underlines
\texttt
{
\large \vens_foo:nnn { #1 } { #2 } { #3 }
}
}
\cs_new_protected:Nn \vens_foo:nnn
{
\vens_foo_lines:Nn \doubleunderline { #2 }
\vens_foo_lines:Nn \underline { #3 }
#1
}
\cs_new_protected:Nn \vens_foo_lines:Nn
{
\makebox[0pt][l]{\tl_map_tokens:nn { #2 } { \__vens_foo_line:Nn #1 }}
}
\cs_new_protected:Nn \__vens_foo_line:Nn
{
\int_compare:nTF { #2 = 0 }
{ \hspace{0.5em} }
{ #1{\hspace{0.5em}\vphantom{Ay}} }
}
\ExplSyntaxOff
\begin{document}
\foo{abacaccababa}{100000000001}{111000000111}
\medskip
\foo{abacaccababa}{111011100111}{001110011100}
\end{document}
这导致
答案2
您可以将上方和下方的划线指定为二进制字符串:
\documentclass{article}
\ExplSyntaxOn
\NewDocumentCommand{\textoverline}{m}
{
\ensuremath{\overline{\mbox{#1}}}
}
\NewDocumentCommand{\foo}{mmm}
{% #1 = string
% #2 = overlines
% #3 = underlines
\texttt
{
\large \vens_foo:nnn { #1 } { #2 } { #3 }
}
}
\cs_new_protected:Nn \vens_foo:nnn
{
\vens_foo_lines:Nn \textoverline { #2 }
\vens_foo_lines:Nn \underline { #3 }
#1
}
\cs_new_protected:Nn \vens_foo_lines:Nn
{
\makebox[0pt][l]{\tl_map_tokens:nn { #2 } { \__vens_foo_line:Nn #1 }}
}
\cs_new_protected:Nn \__vens_foo_line:Nn
{
\int_compare:nTF { #2 = 0 }
{ \hspace{0.5em} }
{ #1{\hspace{0.5em}\vphantom{Ay}} }
}
\ExplSyntaxOff
\begin{document}
\foo{abacaccababa}{100000000001}{111000000111}
\medskip
\foo{abacaccababa}{111011100111}{001110011100}
\end{document}