summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/plantslabels/plantslabels.sty
blob: 76dd1a4f17cce5fa7dd74472f5d94ee74dc1e4dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
%% This is file `plantslabels.sty' v1.0 by Merciadri Luca.
% Many thanks to Enrico Gregorio for his help.


\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{plantslabels}[2010/04/05 Writing plant labels]
\PackageInfo{plantslabels}{This is Plantslabels by Merciadri Luca.}

\PassOptionsToPackage{newdimens}{labels}
\RequirePackage{labels}[2003/05/22]
\RequirePackage{graphicx}[2005/12/01]

\LeftPageMargin=2mm% These four parameters give the
\RightPageMargin=2mm% page gutter sizes. The outer edges of
\TopPageMargin=2mm% the outer labels are the specified
\BottomPageMargin=2mm% distances from the edge of the paper.
\InterLabelColumn=1mm% Gap between columns of labels
\InterLabelRow=1mm% Gap between rows of labels
\LeftLabelBorder=5mm% These four parameters give the extra
\RightLabelBorder=5mm% space used around the text on each
\TopLabelBorder=5mm% actual label.
\BottomLabelBorder=5mm%

\newsavebox{\mybox}

\newcommand{\lm@measurebox}[5]{%
  \sbox\mybox{%
    \begin{tabular}{cc}
    \ifx\relax#1\relax\else \textbf{Name} & \textit{#1}\\ \fi
    \ifx\relax#2\relax\else \textbf{Price} & #2\,\ #3\\ \fi
    \ifx\relax#4\relax\else \textbf{Temperature} & #4\\ \fi
    \ifx\relax#5\relax\else \textbf{Substratum} & #5\\ \fi
    \end{tabular}%
  }%
}

\newcommand{\lm@ig}[1]{\multicolumn{2}{c}{%
    \includegraphics[width=0.33\wd\mybox,
      height=0.33\ht\mybox,
      keepaspectratio]{#1}}}

\newcommand{\plant}[9]{%
  \renewcommand{\LabelCols}{#1}%
  \renewcommand{\LabelRows}{#2}%
  \renewcommand{\numberoflabels}{#3}%
  \lm@measurebox{#4}{#5}{#6}{#7}{#8}%
  \addresslabel[\fboxsep=0pt]{%
    \fbox{%
      \begin{tabular}{cc}
      \ifx\relax#4\relax\else \textbf{Name} & \textit{#4}\\ \fi
      \ifx\relax#5\relax\else \textbf{Price} & #5\,\ #6\\ \fi
      \ifx\relax#7\relax\else \textbf{Temperature} & #7\\ \fi
      \ifx\relax#8\relax\else \textbf{Substratum} & #8\\ \fi
      \ifx\relax#9\relax\else \lm@ig{#9} \fi
      \end{tabular}%
    }%
  }%
}
\relax