0

🖖 a newbie here ;)

I'm trying to create a box around every character of a super long string (eg. let's say something like all the unicode chars) loaded from an external file (inputlisting probably?).

I need the boxes to be 1em ✕ 1em to be visually appealing, or any fixed defined size.

I don't know the number of columns that fit into the linewidth and I expect to find a solution that handles breaklines and on multiple pages.

The result should be something like this:

Example

In your opinion is tabular the way to go (eg. this) or something like this to loop over strings?

I feel like ltxtable and other stuff I found reading here and there are the way to go, but there are really dozens packages to handle tables, and I'm not able to find where to start from.

PS. No problem on go with solutions like luatex and similar as long as it works ;)

4

A simple loop with \frameboxes should do. Run with LuaLaTeX (XeLaTeX should also work).

\documentclass{article}
\begin{document}

\newcount\curchar
\noindent
\loop\ifnum\curchar<"10000
    \iffontchar\font\curchar
        \framebox[5ex]{%
            \vrule height 2.5ex depth 1.5ex width 0pt\relax
            \Uchar\curchar
        }\hskip0pt
    \fi
    \advance\curchar by 1
\repeat

\end{document}

First page of output:

enter image description here

3
  • Super, thanks, I'm trying to understand your commands. I was able to reproduce it locally. So it's a loop over the variable curchar that holds the current character that is a number (the first 10000) and is then printed with the \Uchar command, right? Then how to pass an argument of my own string to loop those characters? Another thing I'm also trying to remove the margin... without success :( following this options joshua.smcvt.edu/latex2e/_005cfbox-_0026-_005cframebox.html – pna Apr 13 '20 at 10:30
  • @pna You haven't posted a minimal working example, so this is where it ends. – Henri Menke Apr 13 '20 at 23:06
  • Thanks for your help, then. – pna Apr 13 '20 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.