2

I am working on a board game and want to cut out a prototype of my cards. I set up the cards as a TiKZ picure template and then I put them all in a longtable to have a grid of cards, which I'd print and cut out from the paper. This is a MWE of what I have now:

\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{longtable}

\newcommand{\card}[1]{
\begin{tikzpicture}
\draw (0,0) rectangle (50mm, 70mm);
\node (title) at (25mm, 35mm){ #1 };
\end{tikzpicture}
}

\begin{document}

\begin{longtable}{ c c c }
\card{Card 1}
&
\card{Card 2}
&
\card{Card 3}
\\
\card{Card 4}
&
\card{Card 5}
&
\card{Card 6}
\end{longtable}

\end{document}

Notice that there is space between the cards in the grid, both vertically and horizontally. Ideally, I'd want them to directly touch each other to make cutting them out easier (half the work, since each cut is shared between two cards). Another problem with longtable that I have is that I need to have a \\ every 3 cards, so I have to edit them all each time I add in or remove a card from the list.

I am open to using any other type of environment to put them in a grid, but I'd rather not have to (significantly) change the card template itself.

1 Answer 1

4
  • In order to get rid of the vertical white space between cards in adjacent rows, add [baseline=(current bounding box.center)] as an optional argument to your tikzpicture.

  • To reomve the horizontal white space between cards in adjacent columns, use \setlength{\tabcolsep}{0pt} and add a % after \end{tikzpicture}.

Combining these changes, we end up with the following MWE and output.

enter image description here

\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{longtable}

\newcommand{\card}[1]{%
\begin{tikzpicture}[baseline=(current bounding box.center)]
\draw (0,0) rectangle (50mm, 70mm);
\node (title) at (25mm, 35mm){ #1 };
\end{tikzpicture}%
}

\begin{document}
\setlength{\tabcolsep}{0pt}
\begin{longtable}{ c c c }
\card{Card 1}
&
\card{Card 2}
&
\card{Card 3}
\\
\card{Card 4}
&
\card{Card 5}
&
\card{Card 6}
\end{longtable}

\end{document}
5
  • Thanks. What does the % do? Isn't that just a comment indicator.
    – indjev99
    Dec 29, 2021 at 14:42
  • I see, thanks. One more thing. After adding the [baseline = (current bounding box.center)], something else stopped working. At a few places in the cards I am drawing circles in line with the text like so: \tikz\draw[darkgray, fill = Red] (0,0) circle (\circlesize);. These used to be lined up with the text but now they are not.
    – indjev99
    Dec 29, 2021 at 15:01
  • @indjev99: \tikz[baseline = (current bounding box.south)]\draw[darkgray, fill = Red] (0,0) circle (\circlesize); should fix that.
    – leandriis
    Dec 29, 2021 at 15:07
  • Ah okay. I had tried giving that argument to \draw but I see now how it works. Thanks a lot!
    – indjev99
    Dec 29, 2021 at 15:16

You must log in to answer this question.

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