summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/ncctools/ncccropbox.dtx
blob: e0c80dbd48429749d3d68977dafbd771c29a525d (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
% \iffalse
%%
%% File: ncccropbox.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko
%%
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{ncccropbox}
%<package>         [2004/11/24 v1.1 Crop Box Package (NCC)]
%
% \changes{v1.02}{2002/01/31}{This version is uploaded to CTAN}
% \changes{v1.03}{2002/02/08}{The package is renamed to ncccropbox}
% \changes{v1.1}{2004/11/24}{Documentation was prepared}
%
%<*driver>
\let\makeindex\relax
\documentclass{ltxdoc}
\usepackage{ncccropbox}
\GetFileInfo{ncccropbox.sty}
\begin{document}
\title{The \textsf{ncccropbox} package\thanks{This file
        has version number \fileversion, last
        revised \filedate.}}
\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
\date{\filedate}
\maketitle
\DocInput{ncccropbox.dtx}
\end{document}
%</driver>
% \fi
%
% \section{User Interface}
%
% \DescribeMacro{\cropbox}
% The package implements the command
% \begin{quote}
%   |\cropbox|\oarg{width}\oarg{height}\marg{content}
% \end{quote}
% preparing a horizontal box with crop-marks at its corners looking like angles.
% The crop-box is aligned at the bottom and is lowered at the |\lineskip| value.
% The optional \meta{width} and \meta{height} parameters specify the width and
% height of the crop-box respectively. If some of them is omitted or is
% empty, the width or height of the crop-box \meta{content} is used for calculation
% the omitted dimension. In this case, the doubled value of the
% \textit{crop-box separation\/} parameter is added to the natural dimension
% of the box's \meta{content}. The \meta{content} is centered inside the crop-box.
%
% \DescribeMacro{\cropboxsep}
% The |\cropboxsep|\marg{length} command specifies the separation value to be used
% in calculation of crop-box dimensions when any of optional parameters is
% omitted or empty. The default is |\cropboxsep{5pt}|.
%
% \DescribeMacro{\croplinewidth}
% The |\croplinewidth|\marg{length} command specifies a width of crop-lines.
% The default is |\croplinewidth{.4pt}|.
%
% \DescribeMacro{\croplinelength}
% The |\croplinelength|\marg{length} command specifies a length and direction
% of crop-lines: the absolute value of \meta{length} specifies
% a length of crop-lines and the sign of \meta{length} specifies a direction.
% If the \meta{length} is negative, the angles look outside the crop-box.
% Otherwise, they look inside the crop-box.
%
% The following example shows how crop-boxes are docked together:
% \begin{center}
% \cropbox[30mm][10mm]{Box 1}\cropbox[30mm][10mm]{Box 2}\cropbox[30mm][10mm]{Box 3}\cropbox[30mm][10mm]{Box 4}\\
% \cropbox[30mm][10mm]{Box 5}\cropbox[30mm][10mm]{Box 6}\cropbox[30mm][10mm]{Box 7}\cropbox[30mm][10mm]{Box 8}
% \end{center}
% It was prepared as follows:
% \begin{quote}
% |\begin{center}|\\
% |\cropbox[30mm][10mm]{Box 1}\cropbox[30mm][10mm]{Box 2}%|\\
% |\cropbox[30mm][10mm]{Box 3}\cropbox[30mm][10mm]{Box 4}\\|\\
% |\cropbox[30mm][10mm]{Box 5}\cropbox[30mm][10mm]{Box 6}%|\\
% |\cropbox[30mm][10mm]{Box 7}\cropbox[30mm][10mm]{Box 8}|\\
% |\end{center}|
% \end{quote}
% You can see that crop-lines of neighbour boxes exactly coincide.
% \StopEventually{}
%
% \section{The Implementation}
%
% \begin{macro}{\croplinelength}
% \begin{macro}{\croplinewidth}
% \begin{macro}{\cropboxsep}
% Styling macros:
%    \begin{macrocode}
%<*package>
\newcommand*{\croplinelength}[1]{\def\CRB@length{#1}}
\newcommand*{\croplinewidth}[1]{\def\CRB@width{#1}}
\newcommand*{\cropboxsep}[1]{\def\CRB@sep{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cropbox}
% The |\cropbox| command:
%    \begin{macrocode}
\newcommand*{\cropbox}[1][]{\@ifnextchar[{\CRB@box[#1]}{\CRB@box[#1][]}}
\def\CRB@box[#1][#2]#3{%
%    \end{macrocode}
% Calculate crop-box dimensions in |\@tempdima| and |\@tempdimb|:
%    \begin{macrocode}
  \@begin@tempboxa\hbox{#3}%
    \def\@tempa{#1}\ifx\@tempa\@empty
      \@tempdima\width \advance\@tempdima 2\CRB@sep\relax
    \else
      \setlength\@tempdima{#1}%
    \fi
    \def\@tempa{#2}\ifx\@tempa\@empty
      \@tempdimb\totalheight \advance\@tempdimb 2\CRB@sep\relax
    \else
      \setlength\@tempdimb{#2}%
    \fi
%    \end{macrocode}
% Prepare crop-marks in 0th box of zero width:
%    \begin{macrocode}
    \setbox\z@\hb@xt@\z@{%
      \linethickness{\CRB@width}%
      \setlength\unitlength{\CRB@length}%
      \ifdim\unitlength=\z@ \else
        \ifdim\unitlength>\z@
          \CRB@hcross\z@\z@\@ne\@ne
          \CRB@hcross\@tempdima\z@\m@ne\@ne
          \CRB@hcross\z@\@tempdimb\@ne\m@ne
          \CRB@hcross\@tempdima\@tempdimb\m@ne\m@ne
        \else \unitlength -\unitlength
          \CRB@hcross\z@\z@\m@ne\m@ne
          \CRB@hcross\@tempdima\z@\@ne\m@ne
          \CRB@hcross\z@\@tempdimb\m@ne\@ne
          \CRB@hcross\@tempdima\@tempdimb\@ne\@ne
        \fi
      \fi
    }%
%    \end{macrocode}
% Put crop-marks as a background for vertical box containing the
% crop-box content. We decrease the height of vertical box on
% the |\lineskip| to make the exact docking of vertically neighbour
% crop-boxes.
%    \begin{macrocode}
    \leavevmode \ht\z@\z@ \dp\z@\z@ \box\z@
    \advance\@tempdimb -\lineskip
    \vbox to\@tempdimb{\vss\vskip -\lineskip
      \hb@xt@\@tempdima{\hss\unhbox\@tempboxa\hss}\vss\kern\z@
    }%
  \@end@tempboxa
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CRB@hcross}
% This command prepares a crop-mark.
%    \begin{macrocode}
\def\CRB@hcross#1#2#3#4{%
  \@killglue\raise#2\hb@xt@\z@{\kern#1\line(#3,0)\@ne\hss}\hss
  \@killglue\raise#2\hb@xt@\z@{\kern#1\line(0,#4)\@ne\hss}\hss
}
%    \end{macrocode}
% \end{macro}
%
% Initial settings:
%    \begin{macrocode}
\croplinelength{10pt}
\croplinewidth{.4pt}
\cropboxsep{5pt}
%</package>
%    \end{macrocode}
\endinput