summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/gcard/gcard.sty
blob: 9acc5927d59f6188b3ae4f4d3015c654ae9b8a38 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
% package file for gcard package: typeset four ``panels'' on a single
% sheet so that sheet can be folded twice to produce a greeting card.
% Uses \rotatebox command from the graphicx package to invert two 
% of the panels, and the textpos package to place all four panels on 
% the page.  

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gcard}[2007/05/21 simple greeting card package]
\DeclareOption{showboxes}{\PassOptionsToPackage{showboxes}{textpos}}
\ProcessOptions
\RequirePackage[absolute]{textpos}
\RequirePackage{graphicx}
\RequirePackage{calc}

% main code begins here; each panel will be typeset and stored in 
% the box register \paneltext
\newsavebox{\paneltext}

% Define lengths 
\newlength{\guttermargin}
\newlength{\edgemargin}
\newlength{\gctopmargin}
\newlength{\gcbottommargin}
\newlength{\panelwidth}
\newlength{\panelheight}

% Set default values for margins.  These are the apparent margins after
% the card has been folded.  The user should set these four to taste.
% All four panels use the same margins.
% Here, edge and gutter are set the same, as are top and bottom; that's
% not required, and it's okay to use 4 different values.
\setlength{\guttermargin}{0.2 in} % inside of panel  
\setlength{\edgemargin}{\guttermargin}  % outside
\setlength{\gctopmargin}{0.2 in}        % top
\setlength{\gcbottommargin}{\gctopmargin}  % bottom

% Define environments for four panels.  The two outside ones (frontcover and
% backcover) need to be rotated.
% These environments place the user's material vertically centered in a minipage
% of width \panelwidth and height \panelheight.
\newenvironment{frontcover}{%
\begin{lrbox}{\paneltext}\begin{minipage}[t][\panelheight][c]{\panelwidth}}
{\end{minipage}\end{lrbox}
\begin{textblock*}{\panelwidth}(0pt,0pt)
\noindent
\rotatebox[origin=c]{180}{\usebox{\paneltext}}
\end{textblock*}}

\newenvironment{backcover}{%
\begin{lrbox}{\paneltext}\begin{minipage}[t][\panelheight][c]{\panelwidth}}
{\end{minipage}\end{lrbox}
\begin{textblock*}{\panelwidth}(\TPHorizModule,0pt)
\noindent
\rotatebox[origin=c]{180}{\usebox{\paneltext}}
\end{textblock*}}

\newenvironment{insideleft}{%
\begin{textblock*}{\panelwidth}(0pt,\TPVertModule)
\noindent
\begin{minipage}[t][\panelheight][c]{\panelwidth}}
{\end{minipage}\end{textblock*}}

\newenvironment{insideright}{%
\begin{textblock*}{\panelwidth}(\TPHorizModule,\TPVertModule)
\noindent
\begin{minipage}[t][\panelheight][c]{\panelwidth}}
{\end{minipage}\end{textblock*}}

\AtBeginDocument{
% turn off page numbering
\pagestyle{empty}
% User should have chosen margins by now; compute panel sizes
% and ``step sizes'' for placing panels
\setlength{\panelwidth}{(\paperwidth-2\guttermargin-2\edgemargin)/2}
\setlength{\panelheight}{(\paperheight-2\gctopmargin-2\gcbottommargin)/2}
\setlength{\TPHorizModule}{\panelwidth + 2\guttermargin}
\setlength{\TPVertModule}{\panelheight + 2\gctopmargin}
% Set position of upper left corner of upper left panel (front cover)
% with command from textpos package.
\textblockorigin{\edgemargin}{\gcbottommargin}

}