0

I am trying to generate some cards for a game using a list of words provided in a text file. This is my current approach:

\documentclass[a4paper,10pt]{article}
\usepackage[a4paper,margin=0in]{geometry}
\usepackage{datatool}
\usepackage{multicol}
\usepackage{graphicx}

\DTLloaddb{words}{words.csv}

% Formatting adjustments
\setlength{\parindent}{0pt}
\setlength{\columnsep}{-1pt}

\pagestyle{empty}

\begin{document}
\begin{multicols}{3}
\DTLforeach*{words}{\word=word}{
    \fbox{
    \begin{minipage}[t][0.15\textheight][c]{0.93\linewidth}
        \begin{center}
            \vspace{5pt}
            \includegraphics[width=2cm]{logo.png}
            \vfill
            \textbf{\LARGE \word}
            \vfill
            {\tiny Footer.}
            \vspace{5pt}
        \end{center}
    \end{minipage}
    }
    \vspace{-1pt}
}
\end{multicols}

\end{document}

The output this generates is:

output with a small space after the first card

How can I get rid of this small space in between the first two cards? This only happens on the first page, the second page is correctly aligned.

8
  • Welcome to TeX.SE! Commented Nov 18, 2024 at 15:51
  • 2
    You should try the tcolorbox package. It provides the tcbraster environment to align boxes. Commented Nov 18, 2024 at 15:53
  • I may be mistaken, but the question may be about the very small vertical space between cards "aaa" and "bbb". Is that correct? Commented Nov 18, 2024 at 19:28
  • @bishopcranmer yes that was my question. Using tcbraster works fine, thanks for the hint @jlab. Commented Nov 18, 2024 at 22:14
  • If anyone knows why it does not work using multiple, I would still be interested since I ran into this issue before in other contexts that the first column behaves different from the rest. Commented Nov 18, 2024 at 22:16

1 Answer 1

2

I created a sample document based on jlab's suggestion, utilizing the tcolorbox package and the raster library.

As far as I know, most consumer printers have a built-in margin where they cannot print, typically ranging from 0.3 cm to 0.5 cm from the edge of the paper, which is due to the printer's mechanics needing space to grip and feed the paper. That's why I added margin=0.5 on the geometry package.

\documentclass[a4paper,10pt]{article}

\usepackage[
    a4paper,
    margin=0.5cm, % Set a 0.5 cm margin around the document
    showframe, % Show the margins and layout frame for debugging
]{geometry}

% For including images
\usepackage{graphicx}
% tcolorbox package for designing and rasterizing boxes
\usepackage[most]{tcolorbox}

\usepackage{datatool} % For loading and processing CSV data
% Load 'words.csv', the database should have a column named 'word'
\DTLloaddb{words}{words.csv}

\begin{document}

\begin{tcbraster}[ % Define the raster (grid) for boxes
    raster columns=3, % Arrange the boxes into 3 columns
    raster equal height, % Ensure all boxes in the same row have equal height
    raster column skip=2mm, % Horizontal spacing between columns
    raster row skip=2mm, % Vertical spacing between rows
    colframe=black, % Set the frame color of the boxes to black
    colback=white, % Set the background color of the boxes to white
    size=small, % Set the size of the boxes to small
    enhanced, % Enable advanced features for the boxes
    watermark text={Box \thetcbrasternum}, % Add a watermark indicating the box number
]
% Loop through the rows of the database; assign the column 'word' to \word
\DTLforeach*{words}{\word=word}{% <- important, do not remove
    \begin{tcolorbox}[sharp corners] % Create a box with sharp corners
        \centering % Center-align the contents of the box
        \includegraphics[width=2cm]{logo.png}
        
        \textbf{\LARGE \word} % Display the word from the CSV in bold, large font size
        
        {\tiny Footer.}
    \end{tcolorbox}
}
\end{tcbraster}

\end{document}

sample document

1
  • 1
    Thanks a lot! I think I will go with this approach 👍 Commented Nov 18, 2024 at 22:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.