-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmspposter.sty
515 lines (430 loc) · 14.9 KB
/
mspposter.sty
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
%% mspposter.sty
%% Copyright 2016 Alexander Hewer
%
% This work 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.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Alexander Hewer, email: [email protected]
%
% This work consists of the file mspposter.sty
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mspposter}
\RequirePackage{ifthen}
\RequirePackage{tikz}
\RequirePackage[pass,a4paper]{geometry}
\usetikzlibrary{
calc,
backgrounds,
positioning,
decorations.pathmorphing,
shadows
}
\usepgfmodule{oo}
%\url{http://tex.stackexchange.com/q/33703/86}
\makeatletter
\newcommand{\gettikzxy}[3]{%
\tikz@scan@one@point\pgfutil@firstofone#1\relax
\edef#2{\the\pgf@x}%
\edef#3{\the\pgf@y}%
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% class for poster
\pgfooclass{poster}{
\method poster() {
% setup coordinates for background shading
\coordinate (bgleft) at (-.5\paperwidth,0);
\coordinate (bgright) at (0.5\paperwidth,0);
\coordinate (bgbottom) at (0,-.5\paperheight);
\coordinate (bgupper) at (0,.5\paperheight);
}
% ATTRIBUTES
\attribute columnWidth=20;
\attribute topMargin=20;
\attribute blockHorizontalSpacing=20;
\attribute blockVerticalSpacing=20;
\attribute columnAmount=1;
\attribute currentColumn=1;
\attribute blockPadding=10;
\attribute placementMode=rowFirst;
\attribute currentID=1;
% METHODS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method incrementID() {
\pgfmathparse{int(\pgfoovalueof{currentID} + 1)}
\pgfoolet{currentID}{\pgfmathresult}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method setPlacementMode(#1) {
\pgfooset{placementMode}{#1}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method openBlock(#1) {
\pgfooget{columnWidth}{\currentWidth}
\pgfooget{blockPadding}{\currentPadding}
\pgfooget{currentID}{\currentID}
\node [
#1,
inner sep=\currentPadding pt,
anchor=north west] at (blockanchor) (\currentID)
\bgroup
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method openBlockW(#1){
% this is a block with custom width -> do not count it as a usual column
\pgfmathparse{int(\pgfoovalueof{currentColumn} - 1)}
\pgfoolet{currentColumn}{\pgfmathresult}
\pgfooget{blockPadding}{\currentPadding}
\pgfooget{currentID}{\currentID}
\node [
#1,
inner sep=\currentPadding pt,
anchor=north west] at (blockanchor) (\currentID)
\bgroup
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method openBlockWFill(#1){
% indicate that this is the last column on the row
\pgfooset{currentColumn}{\pgfoovalueof{columnAmount}}
% compute remaining space to right boundary
\gettikzxy{(blockanchor)}{\vx}{\vy}
\pgfmathparse{veclen(0.5 * \textwidth - \vx, 0) - 2 * \pgfoovalueof{blockPadding}}
\let\currentWidth\pgfmathresult
\pgfooget{blockPadding}{\currentPadding}
\pgfooget{currentID}{\currentID}
\node [
#1,
inner sep=\currentPadding pt,
anchor=north west] at (blockanchor) (\currentID)
\bgroup
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method closeBlock(){
\egroup;
\pgfooget{currentID}{\currentID}
% keep track of largest y value
\path let
\p1 = (largesty),
\p2 = (\currentID.south)
in \ifdim \y2 < \y1 coordinate (largesty) at (\x1, \y2)\fi;
% update internal state depending on chosen placement mode
\ifthenelse{\equal{\pgfoovalueof{placementMode}}{rowFirst}}{%
\pgfoothis.updateStateRow()
}{%
% else
\pgfoothis.updateStateColumn()
}
\pgfoothis.incrementID()
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method updateStateRow() {
% check if we are at the last column
\ifthenelse{%
\equal{\pgfoovalueof{columnAmount}}{\pgfoovalueof{currentColumn}}}{%
% yes, move to next row
\pgfoothis.nextRow()%
}{%
% no, increment column number and move to next column
\path let
\p1 = (\currentID.north east)
in coordinate (blockanchor) at (\x1 + \pgfoovalueof{blockHorizontalSpacing}pt, \y1);
\pgfmathparse{int(\pgfoovalueof{currentColumn} + 1)}
\pgfoolet{currentColumn}{\pgfmathresult}
}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method updateStateColumn() {
% move to next row
\path let
\p1 = (\currentID.south west)
in coordinate (blockanchor) at (\x1, \y1 - \pgfoovalueof{blockVerticalSpacing}pt);
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method nextRow(){
% move base anchor to next row
\coordinate (baseanchor) at (largesty -| baseanchor);
% initialize block anchor to first column
\coordinate
[below=\pgfoovalueof{blockVerticalSpacing}pt of baseanchor] (blockanchor);
% return to first column
\pgfooset{currentColumn}{1}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method nextColumn(){
% increment currentColumn
\pgfmathparse{int(\pgfoovalueof{currentColumn} + 1)}
\pgfoolet{currentColumn}{\pgfmathresult}
% compute x-offset to base anchor
\pgfmathparse{
(\pgfoovalueof{currentColumn} - 1) * (
\pgfoovalueof{columnWidth} + \pgfoovalueof{blockHorizontalSpacing} +
2 * \pgfoovalueof{blockPadding}
)
}
% set block anchor for column
\path let
\p1 = (baseanchor)
in coordinate (blockanchor) at
(\x1 + \pgfmathresult pt, \y1 - \pgfoovalueof{blockVerticalSpacing});
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method computeColumnWidth() {
% derive the column width by using the amount of columns, textwidth,
% block padding, and the block spacing
\pgfmathparse{ (
\textwidth
- 2 * \pgfoovalueof{columnAmount} * \pgfoovalueof{blockPadding}
- ( \pgfoovalueof{columnAmount} - 1) * \pgfoovalueof{blockHorizontalSpacing}
) / \pgfoovalueof{columnAmount}
}
\pgfoolet{columnWidth}{\pgfmathresult}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% initializes data structures for current poster block container
\method initRows(#1,#2){
\pgfooset{placementMode}{#2}
\pgfoothis.setColumns(#1)
\coordinate
[below=\pgfoovalueof{blockVerticalSpacing}pt of baseanchor] (blockanchor);
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method setBlockPadding(#1) {
\pgfooset{blockPadding}{#1}
\pgfoothis.updateLayout()
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method setBlockSpacings(#1,#2) {
\pgfooset{blockHorizontalSpacing}{#1}
\pgfooset{blockVerticalSpacing}{#2}
\pgfoothis.updateLayout()
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% set amount of columns
\method setColumns(#1) {
% set column amount
\pgfooset{columnAmount}{#1}
% return to first column after change
\pgfooset{currentColumn}{1}
% compute column width
\pgfoothis.computeColumnWidth()%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method setMargins(#1,#2) {
% modify text width such that poster is centered
\pgfmathparse{\paperwidth - 2 * #1}
\setlength{\textwidth}{\pgfmathresult pt}
\pgfooset{topMargin}{#2}
\pgfoothis.updateLayout()
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method updateLayout() {
\pgfoothis.computeColumnWidth()
\pgfoothis.setupAnchors()
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method setupAnchors() {
% initialize the anchors
% compute y-coordinate for all anchors,
% add blockVerticalSpacing to each y-coordinate, it is removed by the first block
\pgfmathparse{
0.5\paperheight + \pgfoovalueof{blockVerticalSpacing} - \pgfoovalueof{topMargin}}
% anchor for keeping track of largest y-value
\coordinate (largesty) at (0, \pgfmathresult pt);
% base anchor that is used to derive the actual anchors for
% the poster blocks
\coordinate (baseanchor) at (-0.5 * \textwidth, \pgfmathresult pt);
% initialize first block anchor
\coordinate
[below=\pgfoovalueof{blockVerticalSpacing}pt of baseanchor] (blockanchor);
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\method shadeBackground(#1,#2) {
\begin{scope}[on background layer]
\shade [bottom color=#1,top color=#2]
(bgupper -| bgleft) rectangle (bgbottom -| bgright);
\end{scope}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}% end poster class
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\setblockpadding}[1] {
\poster.setBlockPadding(#1)
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\setblockspacing}[1] {
\poster.setBlockSpacings(#1,#1)
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\setblockspacings}[2] {
\poster.setBlockSpacings(#1,#2)
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\setmargins}[2] {
\poster.setMargins(#1,#2)
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\shadebackground}[2] {
\poster.shadeBackground(#1,#2)
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\setbackground}[1] {
\begin{scope}[on background layer]
\node[inner sep=0] at (0, 0) {#1};
\end{scope}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% row first container
\newenvironment{posterrows}[1][1]{
\poster.initRows(#1,rowFirst)
\poster.setColumns(#1)
}{
\poster.nextRow()
\poster.setColumns(1)
\poster.setPlacementMode(rowFirst)
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% column first container
\newenvironment{postercolumns}[1][1]{
\poster.initRows(#1,columnFirst)
\poster.setColumns(#1)
}{
\poster.nextRow()
\poster.setColumns(1)
\poster.setPlacementMode(rowFirst)
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{posterblock}[1][posterblock]{
\poster.openBlock(#1)%
% ignore leading white space
\ignorespaces
% place content inside a minipage
\begin{minipage}{\currentWidth pt}%
}{%
\end{minipage}%
\poster.closeBlock()
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{posterblockW}[3][posterblock]{
% open row block with custom width
\poster.openBlockW(#1)%
% ignore leading white space
\ignorespaces
% place content inside a minipage with specified height and width
\begin{minipage}[c][#3pt][t]{#2 pt}%
}{%
\end{minipage}%
\poster.closeBlock()
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{posterblockWFill}[2][posterblock]{
% open row block and use the remaining horizontal space as width
\poster.openBlockWFill(#1)%
% ignore leading white space
\ignorespaces
% place content inside a minipage with specified height and current text
% width
\begin{minipage}[c][#2pt][t]{\currentWidth pt}%
}{%
\end{minipage}%
\poster.closeBlock()
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{posterblockH}[2][posterblock]{
\poster.openBlock(#1)%
% ignore leading white space
\ignorespaces
% place content inside a minipage with specified height and current text
% width
\begin{minipage}[c][#2pt][t]{\currentWidth pt}%
}{%
\end{minipage}%
\poster.closeBlock()
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\posternextcolumn}{
\poster.nextColumn()
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{logobar}[1][logobar]{
\begin{scope}[on background layer]
\coordinate (logobar) at (0, -0.5\paperheight);
% shift a little bit, such that the bottom border is not visible
\node [#1, above=-4pt of logobar] \bgroup
% ignore leading white space
\ignorespaces
% place content inside a minipage
\begin{minipage}{\textwidth}%
}{%
\end{minipage}%
\egroup;
\end{scope}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% main environment
\newenvironment{poster}[1][themes/default]{%
% remove all margins
\newgeometry{hmargin=0pt, vmargin=0pt, bindingoffset=0pt}
\parindent0pt
% fill the whole page
\begin{tikzpicture}
\node[fill=white,
anchor=north west,
minimum width=\paperwidth,
minimum height=\paperheight] {};
\end{tikzpicture}%
% open the actual tikz picture environment for the poster
\begin{tikzpicture}[overlay,
% shift origin of coordinate system
shift={(-0.5\paperwidth,0.5\paperheight)},
every node/.style={
outer sep=0
}]
% create poster object
\pgfoonew \poster=new poster()
\input{#1}
}{%
\end{tikzpicture}%
% restore old layout
% http://tex.stackexchange.com/questions/136089/change-page-margin-inside-own-environment
\restoregeometry\aftergroup\restoregeometry
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% special environment for shifting the poster
% arg1: theme
% arg2: right shift
% arg3: down shift
\newenvironment{shiftedposter}[3][themes/default]{%
% remove all margins
\newgeometry{hmargin=0pt, vmargin=0pt, bindingoffset=0pt}
\parindent0pt
% fill the whole page
\begin{tikzpicture}
\node[fill=white,
anchor=north west,
minimum width=\paperwidth,
minimum height=\paperheight] {};
\end{tikzpicture}%
% open the actual tikz picture environment for the poster
\begin{tikzpicture}[overlay,
% shift origin of coordinate system
shift={(-0.5\paperwidth + #2,0.5\paperheight - #3)},
every node/.style={
outer sep=0
}]
% create poster object
\pgfoonew \poster=new poster()
\input{#1}
}{%
\end{tikzpicture}%
% restore old layout
% http://tex.stackexchange.com/questions/136089/change-page-margin-inside-own-environment
\restoregeometry\aftergroup\restoregeometry
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%