1

I want to generate multiple tags with different codes on A4 (210mm x 297mm) paper. The idea is to cut the A4 in half horizontally in order to get two wide tags (297mm x 105mm). Therefore, cutting guides (in grey) at both sides in the center would be very useful.

What I want to achieve is something like below:

enter image description here

In order to generate multiple PDFs with the required codes, textmerg package was used in this MWE just to do that by retrieving the codes from a jobname.dat file.

MWE

\documentclass[12pt]{scrartcl}
\usepackage{textmerg}
\usepackage{graphicx}
\usepackage{fontspec}
\setmainfont{Arial Black}
\usepackage{pdflscape}
\begin{document}

\Fields{\onecode\twocode} 

\Merge{jobname.dat}{
  \begin{landscape}
    \pagestyle{empty}
    \centering
\topskip4em \resizebox{!}{0.12\textwidth}{\noindent\onecode} \\ \vspace{6cm} \resizebox{!}{0.12\textwidth}{\noindent\twocode}\\
    \cleardoublepage%    
  \end{landscape}
}
\end{document}

jobname.dat

DDD-GG-XX
DDD-UU-DD-XX
DDD-GG-XX
DDD-PP-VV-XX

The output is not centered and there are no cutting guides. My question, is how can I achieve the following using tikz:

  • two codes per page, each one is centered inside its page
  • ability to scale the text
  • drawing centered grey cutting guides to cut A4 paper into equal halves.
  • making use of the A4 paper in a landscape position leaving a reasonable amount of margin space for an obvious aesthetic reason.
2
  • Have you looked at the flowfram package? Mar 16, 2017 at 21:50
  • no, could you provide a solution using it?
    – doctorate
    Mar 17, 2017 at 5:12

2 Answers 2

3

This creates two frames per page, each .8\paperwidth wide and 4cm high. To remove the edges, use \newflowframe instead of \newflowframe*.

\documentclass[fontsize=60pt,landscape,oneside]{scrartcl}
\usepackage{textmerg}
\usepackage{fontspec}
\setmainfont{Arial Black}
\usepackage{flowfram}

\newlength{\pagebottom}
\pagebottom=\dimexpr 1in+\topmargin+\headheight+\headsep+\textheight-\paperheight\relax
\newlength{\pageedge}
\pageedge=\dimexpr -1in-\oddsidemargin\relax

\newflowframe*{.8\paperwidth}{4cm}{\dimexpr\pageedge+.1\paperwidth}{\dimexpr\pagebottom+.75\paperheight-2cm}
\newflowframe*{.8\paperwidth}{4cm}{\dimexpr\pageedge+.1\paperwidth}{\dimexpr\pagebottom+.25\paperheight-2cm}

\pagestyle{empty}
\Fields{\code}
\parindent=0pt
\begin{document}
\Merge{jobname.dat}{\parbox[c][4cm][c]{\linewidth}{\centering\code}\newpage}
\end{document}

demo


Revised solution: These fill the whole page and use about as large a font as will fit.

Note, one could do the same thing using just the \parboxes if you could figure out how to set the margins to 0 with KOMA.

\documentclass[fontsize=100pt,landscape,oneside]{scrartcl}
\usepackage{textmerg}
\usepackage{fontspec}
\setmainfont{Arial Black}
\usepackage{flowfram}

\newlength{\pagebottom}
\pagebottom=\dimexpr 1in+\topmargin+\headheight+\headsep+\textheight-\paperheight\relax
\newlength{\pageedge}
\pageedge=\dimexpr -1in-\oddsidemargin\relax

\newflowframe{\paperwidth}{.5\paperheight}{\pageedge}{\dimexpr\pagebottom+.5\paperheight}
\newflowframe{\paperwidth}{.5\paperheight}{\pageedge}{\pagebottom}

\pagestyle{empty}
\Fields{\code}
\parindent=0pt
\begin{document}
\Merge{jobname.dat}{\parbox[c][.5\paperheight][c]{\linewidth}{\centering\code}\newpage}
\end{document}

This solution uses TikZ. (It needs to run twice.)

\documentclass[fontsize=100pt,landscape,oneside]{scrartcl}
\usepackage{textmerg}
\usepackage{fontspec}
\setmainfont{Arial Black}
\usepackage{tikz}
\usetikzlibrary{calc}

\pagestyle{empty}
\Fields{\codeone \codetwo}
\begin{document}
\Merge{jobname.dat}{\begin{tikzpicture}[remember picture, overlay]
\node[inner sep=0pt] at ($(current page.center)!.5!(current page.north)$) {\codeone};
\node[inner sep=0pt] at ($(current page.center)!.5!(current page.south)$) {\codetwo};
\end{tikzpicture}
\newpage}
\end{document}
4
  • Yes, could you scale up the text to fill up more space while leaving only a small margin at all sides? However, I cannot accept it as an answer because no tikz code was included.
    – doctorate
    Mar 18, 2017 at 18:10
  • You scale it with the [fontsize=...] option. Why do you want tikz code? Mar 19, 2017 at 1:03
  • tikz is good for scalability, using the positioning library, one can snap whatever text in future to the desired coordinates. This gives more control to position your text.
    – doctorate
    Mar 20, 2017 at 12:26
  • Using TikZ scale does not affect the font size. Mar 20, 2017 at 17:01
0
\documentclass[14pt]{article}
\usepackage[margin=1cm,landscape,nohead,nofoot]{geometry} %option: use `showframe` key to show the frame
\usepackage{textmerg}
\usepackage{xcolor}
\usepackage{graphicx}           % scalebox
\usepackage{fontspec}
\setmainfont{Arial Black}

\begin{document}
\Fields{\onecode\twocode} 
\Merge{jobname.dat}{
  \pagestyle{empty}
  \centering
  \begin{minipage}[][0.5\textheight][c]{\textwidth}
    \centering
    \scalebox{9}[12]{\onecode} % tweak the {x}[y] values
  \end{minipage}
  \textcolor{gray!10!white}{\rule{\linewidth}{1pt}} % cutting guide
  \begin{minipage}[][0.5\textheight][c]{\textwidth}
    \centering
    \scalebox{9}[12]{\twocode}  
  \end{minipage}
  \cleardoublepage%    
}

\end{document}

Output

enter image description here

1
  • I don't see this as an answer for there is not tikz code inside, but it has less complex code than the other solution. The guides would be better if they were on the periphery of the paper not in the middle, which obviously I couldn't do here. I like what the \scalebox can do to fine tune the size of the text.
    – doctorate
    Mar 18, 2017 at 18:26

You must log in to answer this question.

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