vendredi 28 novembre 2014

LabelMaker style alá TEX


I don't own a label maker machine but I've found some A4 paper which have a sticky side. Therefore they can be used as labels. I wrote the following code where the \newLabel command should make a label with a dotted box around it. The outline box is used as a guide when cutting the label with scissors.


One problem that I'm facing is that the boxes I create don't get resized to the words length. This wastes a lot of paper. They should be as close to each other and have an arbitary padding between the borders and letters. Do you have any tips? How may I achieve this goal?



% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode

\documentclass[12pt]{article} % use larger type; default would be 10pt

\usepackage[utf8]{inputenc} % set input encoding (not needed with XeLaTeX)
\usepackage{geometry} % to change the page dimensions
\geometry{a4paper} % or letterpaper (US) or a5paper or....
\geometry{margin=0cm} % for example, change the margins to 2 inches all round

\usepackage{environ}
\usepackage{tikz}

\NewEnviron{elaboration}{
\par
\begin{tikzpicture}

\node[rectangle,minimum width=0.9\textwidth] (m) {
\begin{minipage}{\textwidth}
\BODY
\end{minipage}};

\draw[dashed] (m.south west) rectangle (m.north);
\end{tikzpicture}
}

\newcommand{\newLabel}[1] {
\begin{elaboration}
\uppercase{#1}
\end{elaboration}
}


\begin{document}

\newLabel{$H_2O$}
\newLabel{salt}
\newLabel{High Voltage}
\newLabel{Danger}
\newLabel{DO not touch}

\end{document}


which produces the following PDF: enter image description here


What I want is something like this (with good padding between borders and letters):


enter image description here





Aucun commentaire:

Enregistrer un commentaire