Estou tentando produzir uma matriz que produza a maioria dos caracteres ASCII em uma determinada fonte LaTex. Atualmente, tenho o seguinte código horrível que funciona:
\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[tt=false]{libertine}
\newcommand{\makeasciisymbols}{
ABCDEFGHIJKLMNOPQRSTUVWXYZ%
abcdefghijklmnopqrstuvwxyz%
0123456789()[]\{\}<>=+-*/\%,.;:?!@\&\#\$\_%
}
\newcommand{\makeasciirow}[1]{%
{\fontfamily{#1}\selectfont A}&%
{\fontfamily{#1}\selectfont B}&%
{\fontfamily{#1}\selectfont C}&%
{\fontfamily{#1}\selectfont D}&%
{\fontfamily{#1}\selectfont E}&%
{\fontfamily{#1}\selectfont F}&%
{\fontfamily{#1}\selectfont G}&%
{\fontfamily{#1}\selectfont H}&%
{\fontfamily{#1}\selectfont I}&%
{\fontfamily{#1}\selectfont J}&%
{\fontfamily{#1}\selectfont K}&%
{\fontfamily{#1}\selectfont L}&%
{\fontfamily{#1}\selectfont M}&%
{\fontfamily{#1}\selectfont N}&%
{\fontfamily{#1}\selectfont O}&%
{\fontfamily{#1}\selectfont P}&%
{\fontfamily{#1}\selectfont Q}&%
{\fontfamily{#1}\selectfont R}&%
{\fontfamily{#1}\selectfont S}&%
{\fontfamily{#1}\selectfont T}&%
{\fontfamily{#1}\selectfont U}&%
{\fontfamily{#1}\selectfont V}&%
{\fontfamily{#1}\selectfont W}&%
{\fontfamily{#1}\selectfont X}&%
{\fontfamily{#1}\selectfont Y}&%
{\fontfamily{#1}\selectfont Z}&%
{\fontfamily{#1}\selectfont a}&%
{\fontfamily{#1}\selectfont b}&%
{\fontfamily{#1}\selectfont c}&%
{\fontfamily{#1}\selectfont d}&%
{\fontfamily{#1}\selectfont e}&%
{\fontfamily{#1}\selectfont f}&%
{\fontfamily{#1}\selectfont g}&%
{\fontfamily{#1}\selectfont h}&%
{\fontfamily{#1}\selectfont i}&%
{\fontfamily{#1}\selectfont j}&%
{\fontfamily{#1}\selectfont k}&%
{\fontfamily{#1}\selectfont l}&%
{\fontfamily{#1}\selectfont m}&%
{\fontfamily{#1}\selectfont n}&%
{\fontfamily{#1}\selectfont o}&%
{\fontfamily{#1}\selectfont p}&%
{\fontfamily{#1}\selectfont q}&%
{\fontfamily{#1}\selectfont r}&%
{\fontfamily{#1}\selectfont s}&%
{\fontfamily{#1}\selectfont t}&%
{\fontfamily{#1}\selectfont u}&%
{\fontfamily{#1}\selectfont v}&%
{\fontfamily{#1}\selectfont w}&%
{\fontfamily{#1}\selectfont x}&%
{\fontfamily{#1}\selectfont y}&%
{\fontfamily{#1}\selectfont z}&%
{\fontfamily{#1}\selectfont 0}&%
{\fontfamily{#1}\selectfont 1}&%
{\fontfamily{#1}\selectfont 2}&%
{\fontfamily{#1}\selectfont 3}&%
{\fontfamily{#1}\selectfont 4}&%
{\fontfamily{#1}\selectfont 5}&%
{\fontfamily{#1}\selectfont 6}&%
{\fontfamily{#1}\selectfont 7}&%
{\fontfamily{#1}\selectfont 8}&%
{\fontfamily{#1}\selectfont 9}&%
{\fontfamily{#1}\selectfont (}&%
{\fontfamily{#1}\selectfont )}&%
{\fontfamily{#1}\selectfont [}&%
{\fontfamily{#1}\selectfont ]}&%
{\fontfamily{#1}\selectfont \{}&%
{\fontfamily{#1}\selectfont \}}&%
{\fontfamily{#1}\selectfont <}&%
{\fontfamily{#1}\selectfont >}&%
{\fontfamily{#1}\selectfont =}&%
{\fontfamily{#1}\selectfont +}&%
{\fontfamily{#1}\selectfont -}&%
{\fontfamily{#1}\selectfont *}&%
{\fontfamily{#1}\selectfont /}&%
{\fontfamily{#1}\selectfont \%}&%
{\fontfamily{#1}\selectfont ,}&%
{\fontfamily{#1}\selectfont .}&%
{\fontfamily{#1}\selectfont ;}&%
{\fontfamily{#1}\selectfont :}&%
{\fontfamily{#1}\selectfont ?}&%
{\fontfamily{#1}\selectfont !}&%
{\fontfamily{#1}\selectfont @}&%
{\fontfamily{#1}\selectfont \&}&%
{\fontfamily{#1}\selectfont \#}&%
{\fontfamily{#1}\selectfont \$}&%
{\fontfamily{#1}\selectfont \_}%
}
Usado da seguinte maneira:
\begin{document}
\tiny
\addtolength{\tabcolsep}{-0.9em}
\begin{tabular}{ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc}
Adventor & \texttt{qag} & \makeasciirow{qag} \\
Bonum & \texttt{qbk} & \makeasciirow{qbk} \\
Chorus & \texttt{qzc} & \makeasciirow{qzc} \\
\end{tabular}
\end{document}
Questão 1:como automatizar a criação do \makeasciirow
comando a partir \makeasciisymbols
daquele analisando cada caractere dele ( \&
sendo analisado como um caractere e não dois) e transformando-o em uma coluna?
Questão 2:como contar os caracteres dentro \makeasciisymbols
e transformá-lo em uma linha correspondente c
para automatizar a criação do tabular com o número certo de colunas?
Responder1
Não sei por que você está carregando libertine
isso basicamente não faz nada.
Defina a sequência de caracteres como uma lista de tokens constante. Em seguida, você pode preencher uma sequência com os caracteres sujeitos \fontfamily{#1}\selectfont
e entregar a sequência &
entre os itens.
\documentclass{standalone}
\usepackage[T1]{fontenc}
\ExplSyntaxOn
\tl_const:Nn \c_vincent_ascii_tl
{
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
0123456789
()[]\{\}<>=+-*/\%,.;:?!@\&\#\$\_
}
\seq_new:N \l_vincent_ascii_row_seq
\NewDocumentCommand{\makeasciirow}{m}
{
\seq_clear:N \l_vincent_ascii_row_seq
\tl_map_inline:Nn \c_vincent_ascii_tl
{
\seq_put_right:Nn \l_vincent_ascii_row_seq { \fontfamily{#1}\selectfont ##1 }
}
\seq_use:Nn \l_vincent_ascii_row_seq { & }
}
\NewExpandableDocumentCommand{\ncol}{}{\int_eval:n { \tl_count:N \c_vincent_ascii_tl + 2 } }
\ExplSyntaxOff
\begin{document}
\tiny
\setlength{\tabcolsep}{0.5pt}
\begin{tabular}{*{\ncol}{c}}
Adventor & \texttt{qag} & \makeasciirow{qag} \\
Bonum & \texttt{qbk} & \makeasciirow{qbk} \\
Chorus & \texttt{qzc} & \makeasciirow{qzc} \\
\end{tabular}
\end{document}