summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/menucard/menucard.dtx
blob: da45e9a78f4ed79bc787a3e9ff3e7b82dc24d254 (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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
% \iffalse meta-comment
%
% Copyright (C) 2020 by Sascha Frank <menucard@sascha-frank.com>
% -------------------------------------------------------
% 
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
% and version 1.3 or later is part of all distributions of LaTeX 
% version 2005/12/01 or later.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{menucard.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{menucard}
%<*package>
    [2020/06/17 v0.1 menucards ]
\RequirePackage[x11names]{xcolor}
\RequirePackage{soul}
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{menucard}[2020/06/17]
\usepackage{hyperref}
\usepackage{parskip}
\EnableCrossrefs         
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{menucard.dtx}
  \PrintChanges
  \PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{162}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v0.1}{2020/06/17}{Initial version}
%
% \GetFileInfo{menucard.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
% 
%
% \title{The \textsf{menucard} package\thanks{This document
%   corresponds to \textsf{menucard}~\fileversion, dated \filedate.}}
% \author{Sascha Frank \\ \texttt{menucard@sascha-frank.com}}
%
% \maketitle
% \begin{abstract}
% The reason for this package was that I did not find a package for creating menus.
% \end{abstract}
%
% \section{Introduction}
% The usepackage is based on the answer of Gonzalo Medina\footnote{See also \href{https://tex.stackexchange.com/questions/38091}{https://tex.stackexchange.com/questions/38091}} to the question about a document class for restaurant menus.\cite{medina}
% 
%
% \section{What you need}
% It requires the usepackages soul and xcolor. 
% \section{Loading}
% Load the package with: \verb+\usepackage{menucard}+ 
% 
% \section{Usage}
% \DescribeMacro{\ColTextColor}
% This macro sets the color of the menu heading. Default is Goldenrod3. Change color: 
% \begin{verbatim}
%   \definecolor{plumt}{rgb}{0.56, 0.27, 0.52}
%   \renewcommand{\ColTextColor}{plumt}
%  \end{verbatim}
%
% \DescribeMacro{\ColSubTextColor} 
% To set the color for the second heading. By default 50\% opacity of the first color.
%
% \DescribeMacro{\zapf}
% With the command \verb+\zapf+ the font for the numbering can be changed. For example change to sans serif font \verb+\renewcommand{\zapf}{\sffamily}+ or to use normalfont \verb+\renewcommand{\zapf}{}+.
%
% \DescribeMacro{\Allergens}
% To label allergenes and additives.
% \begin{verbatim}
%   \Allergens{A,B,C}
%  \end{verbatim}
%
%
% \subsection{menugroup}
% There are three new environments, for each there is an additional star alternative.  The variant without a star is intended for the case that the menus are to be numbered consecutively. In the variant with a star, the menus are not numbered consecutively. For this reason there are two different commands to insert entries. One is the command \verb+\Entry+ for the star environments and \verb+\Entrycount+ for the others.
%
% The environments Group and Group* have one parameter. 
%
% \DescribeEnv{Group*}
% Creates a two-column table over the width of the text, with the first column left-aligned (p-column) and the second column right-aligned.
%
%    \begin{verbatim}
%    \begin{Group*}{heading}
%      ...
%    \end{Group*}
%    \end{verbatim}
%    
% \DescribeEnv{Group} 
%Creates a three-column table of the width of the text, with the first two columns left-aligned (p-columns) and the third column right-aligned. The first column is intended for numbering.
%
%    \begin{verbatim}
%    \begin{Group}{heading}
%      ...
%    \end{Group}
%    \end{verbatim}
% 
% The following environments have two parameters.
%
% \DescribeEnv{menugroup*}
%Creates a two-column table over the width of the column, where the first two columns are left-aligned (p-column) and the second column is right-aligned. The text size is \verb+\huge+ for the first heading and \verb+\LARGE+ for the second heading. The colors of the heading are Goldenrod3 respectively 50\% of it by default. A horizontal line is drawn after the headings.
%
%    \begin{verbatim}
%    \begin{menugroup*}{first heading}{second heading}
%      ...
%    \end{menugroup*}
%    \end{verbatim}
% 
% \DescribeEnv{menugroup}
%Like menugroup* but with an additional third column for numbering.
%
%    \begin{verbatim}
%    \begin{menugroup}{first heading}{second heading}
%      ...
%    \end{menugroup}
%    \end{verbatim}
% 
% \DescribeEnv{menugroupsc*}
%Like menugroup* only that the headings are set in small caps.
%
%    \begin{verbatim}
%    \begin{menugroupsc*}{first heading}{second heading}
%      ...
%    \end{menugroupsc*}
%    \end{verbatim}
% 
% \DescribeEnv{menugroupsc}
%Like menugroup only that the headings are set in small caps.
%
%    \begin{verbatim}
%    \begin{menugroupsc}{first heading}{second heading}
%      ...
%    \end{menugroupsc}
%    \end{verbatim}
% 
% To set the menu entries within the environments the commands \verb+\Entry+ or \verb+\Entrycount+. Within these commands, the command \verb+\Expl+ can be used to insert additional explanations.
%
% \DescribeMacro{\Entry}
% Used within the star environments with \verb+\Entry{left}{right}+ respectively with \verb+\Entry{left, \Expl{more}}{right}+. 
%
% \DescribeMacro{\Entrycount}
% Used within the no star environments with \verb+\Entrycount{left}{right}+ respectively with \verb+\Entrycount{left, \Expl{more}}{right}+. 
%
% \DescribeMacro{\Expl}
% Can be used within \verb+\Entry+ respectively \verb+\Entrycount+ to write sub entries.
%
%
%
% \StopEventually{}
%
% \section{Implementation}
%
% Setting color
% \begin{macro}{\ColTextColor}
%   \begin{macrocode}
\newcommand{\ColTextColor}{Goldenrod3}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\ColSubTextColor}
%   \begin{macrocode}
\newcommand{\ColSubTextColor}{\ColTextColor!50}
%    \end{macrocode}
%  \end{macro}
% Text color first heading 
% \begin{macro}{\ColText}
%   \begin{macrocode}
\newcommand*\ColText[1]{\textcolor{\ColTextColor}{#1}}
%    \end{macrocode}
%  \end{macro}
% Text color second heading
% \begin{macro}{\ColSubText}
%   \begin{macrocode}
\newcommand*\ColSubText[1]{\textcolor{\ColSubTextColor}{#1}}
%    \end{macrocode}
%  \end{macro}
% Counter
% \begin{macro}{menucount}
%   \begin{macrocode}
\newcounter{menucount}
%    \end{macrocode}
%  \end{macro}
% New font for numbers
% \begin{macro}{\zapf}
%   \begin{macrocode}
\newcommand{\zapf}{\fontfamily{pzc}\selectfont}
%    \end{macrocode}
%  \end{macro}
% Allergens
% \begin{macro}{\Allergens}
%   \begin{macrocode}
\newcommand{\Allergens}[1]{\textsuperscript{\tiny\sffamily #1}}
%    \end{macrocode}
%  \end{macro}
%  to format each entry in ENV*
% \begin{macro}{\Entry}
%   \begin{macrocode}
\newcommand*\Entry[2]{%
  \sffamily#1 & #2}
%    \end{macrocode}
%  \end{macro}
% to format each subentry
% \begin{macro}{\Expl}
%   \begin{macrocode}
\newcommand*\Expl[1]{%
  \hspace*{1em}\footnotesize #1}
%    \end{macrocode}
%  \end{macro}
% to format each entry in ENV
% \begin{macro}{\Entrycount}
%   \begin{macrocode}
\newcommand*\Entrycount[2]{\stepcounter{menucount} %
  \zapf{\themenucount}\hspace*{1em} & \sffamily#1 & #2 }
%    \end{macrocode}
%  \end{macro}
%
% \begin{environment}{Group*}
% a tabular* for each food group
%    \begin{macrocode}
\newenvironment{Group*}[1]{
  \noindent\begin{tabular*}{\textwidth}{@{}p{.8\linewidth}@{\extracolsep{\fill}}r@{}}
    {\fontsize{24}{29}\selectfont\ColText{#1}}\\[0.8em]}
  {\end{tabular*}}
%    \end{macrocode}
% \end{environment}
% adding an extra column for counting
% \begin{environment}{Group}
%    \begin{macrocode}
\newenvironment{Group}[1]
  {\noindent\begin{tabular*}{\textwidth}{p{2em}@{}p{.8\linewidth}@{\extracolsep{\fill}}r@{}}
    \multicolumn{3}{l}{{\fontsize{24}{29}\selectfont\ColText{#1}}}\\[0.8em]}
  {\end{tabular*}}
%    \end{macrocode}
%\end{environment}
% Change width and font size and added two headings
% \begin{environment}{menugroup*}
%    \begin{macrocode}
\newenvironment{menugroup*}[2]
  {
\noindent\begin{tabular*}{\columnwidth}{@{}p{.8\linewidth}@{\extracolsep{\fill}}r@{}}
    {\huge\textcolor{\ColTextColor}{#1}\hspace*{0.1em} 
    \LARGE\textcolor{\ColSubTextColor}{#2}}\\[0.2em] 
 \noindent\rule{\columnwidth}{0.4pt} & \\[0.8em]}
  {\end{tabular*}}
%    \end{macrocode}
%\end{environment}
%  Adding an extra column for counting
% \begin{environment}{menugroup}
%    \begin{macrocode}
\newenvironment{menugroup}[2]
  {
\noindent\begin{tabular*}{\columnwidth}{p{2em}@{}p{.8\linewidth}@{\extracolsep{\fill}}r@{}}
    \multicolumn{3}{l}{\hspace*{-0.5em}{\huge\textcolor{\ColTextColor}{#1}\hspace*{0.1em} \LARGE\textcolor{\ColSubTextColor}{#2}}}\\[0.2em] 
 \noindent\hspace*{-0.55em}\rule{\columnwidth}{0.4pt} & \\[0.8em]}
  {\end{tabular*}}
%    \end{macrocode}
% \end{environment}
% Adding caps for headings
% \begin{environment}{menugroupsc*}
%    \begin{macrocode}
\newenvironment{menugroupsc*}[2]
  {
\noindent\begin{tabular*}{\columnwidth}{@{}p{.8\linewidth}@{\extracolsep{\fill}}r@{}}
    {\huge\textcolor{\ColTextColor}{\caps{#1}}\hspace*{0.1em} \LARGE\textcolor{\ColSubTextColor}{\caps{#2}}}\\[0.2em] 
 \noindent\rule{\columnwidth}{0.4pt} & \\[0.8em]}
  {\end{tabular*}}
%    \end{macrocode}
%\end{environment}
%  Adding an extra column for counting
% \begin{environment}{menugroupsc}
%    \begin{macrocode}
\newenvironment{menugroupsc}[2]
  {
\noindent\begin{tabular*}{\columnwidth}{p{2em}@{}p{.8\linewidth}@{\extracolsep{\fill}}r@{}}
    \multicolumn{3}{l}{\hspace*{-0.5em}{\huge\textcolor{\ColTextColor}{\caps{#1}}\hspace*{0.1em} \LARGE\textcolor{\ColSubTextColor}{\caps{#2}}}}\\[0.2em] 
 \noindent\hspace*{-0.55em}\rule{\columnwidth}{0.4pt} & \\[0.8em]}
  {\end{tabular*}}
%    \end{macrocode}
%\end{environment}
%
%
%\begin{thebibliography}{9}
%\bibitem{medina}{Gonzalo Medina, 2011/12/13, class for a restaurant menu,\\ \href{https://tex.stackexchange.com/questions/38091/document-class-for-a-restaurant-menu}{https://tex.stackexchange.com/questions/38091/document-class-for-a-restaurant-menu}}
%\end{thebibliography}
%\bibliographystyle{unsrtdin}
% \Finale
\endinput