Estoy intentando producir una matriz que genere la mayoría de los caracteres ascii en una fuente LaTex determinada. Actualmente, tengo el siguiente código horrible 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 \_}%
}
Se utiliza de la siguiente manera:
\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}
Pregunta 1:¿Cómo automatizar la creación del \makeasciirow
comando a partir de \makeasciisymbols
uno analizando cada carácter ( \&
analizado como un carácter y no dos) y convirtiéndolo en una columna?
Pregunta 2:¿Cómo contar los caracteres del interior \makeasciisymbols
y convertirlos en una línea correspondiente c
para automatizar la creación del tabular con el número correcto de columnas?
Respuesta1
No estoy seguro de por qué estás cargando libertine
algo que básicamente no hace nada.
Defina la secuencia de caracteres como una lista de tokens constante. Luego puede completar una secuencia con los caracteres sujetos a \fontfamily{#1}\selectfont
y entregar la secuencia con &
elementos intermedios.
\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}