4

The following code utilizes the tcolorbox package to create a template of a round rectangle gamebox. A simple \foreach statement prints gamebox with the strings Lv. 0 to Lv. 103 printed on them. I nulled before and overrode after to \hfill so that the boxes are well-aligned, making it easy to cut them. \noindent was included in the loop to prevent the first line's indentation.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[a4paper,landscape,left=0.7cm,right=0.7cm,top=0.5cm,bottom=0.5cm]{geometry}
\usepackage{tcolorbox}
\tcbuselibrary{most}
\usepackage{tikz}
\title{}
\author{}
\begin{document}

\newtcbox{\gamebox} {
fontupper=\fontsize{0.7cm}{0.7cm}\selectfont\bfseries,
width=3cm,
boxrule=0.1cm,
height=1.5cm,
halign=center,
valign=center,
before=,
after=\hfill,
tcbox width=forced center
}

\foreach \i in {0,...,103} {
    \noindent
    \gamebox{Lv. \i}
}
\end{document}

However the last line(96 to 103) of the PDF output is a bit off. Regardless of how I adjust the page margins and box sizes, the last line seems to have a slightly smaller \hfill than the others, and the difference becomes noticeable in the latter columns. Does LaTeX reserve space for the end of the last line by default? If so how can I disable this function to get a perfect 8x13 placement?

1 Answer 1

3

You have after every box an \hfill provided by the tcolorbox, a normal space (the one introduced by the end-of-line after \gamebox{Lv. \i}, which can shrink or stretch a little), and a final space after you close the \foreach, after the last }. Finally, there is an end-of-paragraph, which makes the normal spaces their nominal size (more or less, I think it's an \hfil). So the spaces in the normal lines and the last one are not exactly the same size.

enter image description here

You can for example remove the last (end-of-paragraph) space with an \unskip at the end:

...    
    \gamebox{Lv. \i}
}\unskip
...

enter image description here

Or remove every spurious space:

...
\foreach \i in {0,...,103} {%
    \noindent
    \gamebox{Lv. \i}%
}%
...

enter image description here

Anyway, to put things in a grid, I would use a tabular structure (and tcolorbox has a "roster" functionality) to create similar things.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .