Added croatian translations
[amuse-wiki:amuse-wiki.git] / templates / merge.tt
1 % -*- mode: tex -*-
2 \enablemode[<% modes %>]
3
4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 %                                STANDARD                                      %
6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 \definefontfeature[default][default]
8                   [protrusion=quality,
9                     expansion=quality]
10                     script=latn]
11 \setupalign[hz,hanging]
12 \setuptolerance[tolerant]
13 \setbreakpoints[compound]
14 \setupindenting[yes,1em]
15 \setupfootnotes[way=bychapter,align={hz,hanging}]
16 \setupbodyfont[xits,11pt]
17 \setupcaptions[width=\textwidth]
18
19 \setuppagenumbering[alternative=singlesided,location={footer,middle}]
20 \setupcaptions[width=fit,align={hz,hanging}]
21
22 \setupheads[%
23   sectionnumber=no,number=no,
24   align=flushleft,
25   align={flushleft,nothyphenated,verytolerant,stretch},
26   indentnext=yes,
27   tolerance=verytolerant]
28
29 \definehead[awikipart][chapter]
30
31 \setuphead[awikipart]
32           [%
33             number=no,
34             footer=empty,
35             style=\bfd,
36             before={\blank[force,2*big]},
37             align={middle,nothyphenated,verytolerant,stretch},
38             after={\page[yes]}
39           ]
40
41 % <h3>
42 \setuphead[chapter]
43           [style=\bfc]
44
45 \setuphead[title]
46           [style=\bfc]
47
48
49 % <h4>
50 \setuphead[section]
51           [style=\bfb]
52
53 % <h5>
54 \setuphead[subsection]
55           [style=\bfa]
56
57 % <h6>
58 \setuphead[subsubsection]
59           [style=bold]
60
61
62 \setuplist[awikipart]
63           [alternative=b,
64             interaction=all,
65             width=0mm,
66             distance=0mm,
67             before={\blank[medium]},
68             after={\blank[small]},
69             style=\bfa,
70             criterium=all]
71 \setuplist[chapter]
72           [alternative=c,
73             interaction=all,
74             width=1mm,
75             before={\blank[small]},
76             style=bold,
77             criterium=all]
78 \setuplist[section]
79           [alternative=c,
80             interaction=all,
81             width=1mm,
82             style=\tf,
83             criterium=all]
84 \setuplist[subsection]
85           [alternative=c,
86             interaction=all,
87             width=8mm,
88             distance=0mm,
89             style=\tf,
90             criterium=all]
91 \setuplist[subsubsection]
92           [alternative=c,
93             interaction=all,
94             width=15mm,
95             style=\tf,
96             criterium=all]
97
98
99
100
101 %<blockquote>
102
103 \definestartstop
104   [blockquote]
105   [before={\blank[big]
106     \setupnarrower[middle=1em]
107     \startnarrower
108     \setupindenting[no]
109     \setupwhitespace[medium]},
110   after={\stopnarrower
111     \blank[big]}]
112
113
114 \definestartstop
115   [awikibiblio]
116   [before={%
117       \blank[big]
118       \setupnarrower[left=1em]
119       \startnarrower[left]
120         \setupindenting[yes,-1em,first]},
121     after={\stopnarrower
122       \blank[big]}]
123                 
124 % same as above, but with no spacing around
125 \definestartstop
126   [awikiplay]
127   [before={%
128       \setupnarrower[left=1em]
129       \startnarrower[left]
130         \setupindenting[yes,-1em,first]},
131     after={\stopnarrower}]
132
133
134
135 % interaction
136 \setupinteraction[state=start,color=black,contrastcolor=black,style=bold]
137 \placebookmarks[awikipart,chapter,section,subsection,subsubsection][force=yes]
138 \setupinteractionscreen[option=bookmark]
139
140 \setupexternalfigures[%
141   maxwidth=\textwidth,
142   maxheight=\textheight,
143   factor=fit]
144
145 \setupitemgroup[itemize][each][packed][indenting=no]
146
147 \definemakeup[titlepage][pagestate=start,doublesided=no]
148
149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
150 %                                IMPOSER                                       %
151 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
152
153 \startusercode
154
155 function optimize_signature(pages,min,max)
156    local minsignature = min or 40
157    local maxsignature = max or 80
158    local originalpages = pages
159
160    -- here we want to be sure that the max and min are actual *4
161    if (minsignature%4) ~= 0 then
162       global.texio.write_nl('term and log', "The minsig you provided is not a multiple of 4, rounding up")
163       minsignature = minsignature + (4 - (minsignature % 4))
164    end
165    if (maxsignature%4) ~= 0 then
166       global.texio.write_nl('term and log', "The maxsig you provided is not a multiple of 4, rounding up")
167       maxsignature = maxsignature + (4 - (maxsignature % 4))
168    end
169    global.assert((minsignature % 4) == 0, "I suppose something is wrong, not a n*4")
170    global.assert((maxsignature % 4) == 0, "I suppose something is wrong, not a n*4")
171
172    --set needed pages to and and signature to 0
173    local neededpages, signature = 0,0
174
175    -- this means that we have to work with n*4, if not, add them to
176    -- needed pages 
177    local modulo = pages % 4
178    if modulo==0 then
179       signature=pages
180    else
181       neededpages = 4 - modulo
182    end
183
184    -- add the needed pages to pages
185    pages = pages + neededpages
186    
187    if docarguments then 
188       -- give a try with the signature
189       signature = find_signature(pages, maxsignature)
190       
191       -- if the pages, are more than the max signature, find the right one
192       if pages>maxsignature then
193          while signature<minsignature do
194             pages = pages + 4
195             neededpages = 4 + neededpages
196             signature = find_signature(pages, maxsignature)
197             --         global.texio.write_nl('term and log', "Trying signature of " .. signature)
198          end
199       end
200       global.texio.write_nl('term and log', "Parameters:: maxsignature=" .. maxsignature ..
201                    " minsignature=" .. minsignature)
202    else
203       signature = pages
204    end
205    global.texio.write_nl('term and log', "ImposerMessage:: Original pages: " .. originalpages .. "; " .. 
206          "Signature is " .. signature .. ", " ..
207          neededpages .. " pages are needed, " .. 
208          pages ..  " of output")
209    -- let's do it
210    tex.print("\\dorecurse{" .. neededpages .. "}{\\page[empty]}")
211
212 end
213
214 function find_signature(number, maxsignature)
215    global.assert(number>3, "I can't find the signature for" .. number .. "pages")
216    global.assert((number % 4) == 0, "I suppose something is wrong, not a n*4")
217    local i = maxsignature
218    while i>0 do
219       -- global.texio.write_nl('term and log', "Trying " .. i  .. "for max of " .. maxsignature)
220       if (number % i) == 0 then
221          return i
222       end
223       i = i - 4
224    end
225 end
226
227 \stopusercode
228
229
230
231 \define[1]\fillthesignature{
232   \usercode{optimize_signature(#1, <% sigmin %>, <% sigmax %>)}
233
234
235 \define\alibraryflushpages{
236   \page[yes] % reset the page
237   \fillthesignature{\the\realpageno}
238   \page[blank]
239 }
240
241
242 % various papers 
243 \definepapersize[halfletter][width=5.5in,height=8.5in]
244 \definepapersize[halfafour][width=148.5mm,height=210mm]
245 \definepapersize[quarterletter][width=4.25in,height=5.5in]
246 \definepapersize[halfafive][width=105mm,height=148mm]
247
248 \startmode[libertine]
249   \usetypescript[libertine]
250   \setupbodyfont[libertine,11pt]
251 \stopmode
252
253 \startmode[pagella]
254   \setupbodyfont[pagella,11pt]
255 \stopmode
256
257 \startmode[antykwa]
258   \setupbodyfont[antykwa-poltawskiego,11pt]
259 \stopmode
260
261 \startmode[iwona]
262   \setupbodyfont[iwona-medium,11pt]
263 \stopmode
264
265 \startmode[helvetica]
266   \setupbodyfont[heros,11pt]
267 \stopmode
268
269 \startmode[century]
270   \setupbodyfont[schola,11pt]
271 \stopmode
272
273 \startmode[modern]
274   \setupbodyfont[latinmodern,11pt]
275 \stopmode
276
277 \startmode[charis]
278   \setupbodyfont[charis,11pt]
279 \stopmode        
280
281 \startmode[mini]
282   \setuppapersize[S33][S33] % 176 × 176 mm
283   \setuplayout[%
284     backspace=20pt,
285     topspace=15pt,% 176 / 15
286     height=280pt,%130mm,
287     footer=20pt, %
288     header=0pt, % no header
289     width=260pt] % 10.5 x 11
290 \stopmode
291
292 % for the plain A4 and letter, we use the classic LaTeX dimensions
293 % from the article class
294 \startmode[a4]
295   \setuppapersize[A4][A4]
296   \setuplayout[%
297     backspace=42mm,
298     topspace=45mm,
299     height=218mm,
300     footer=10mm,
301     header=0pt, % no header
302     width=126mm]
303 \stopmode
304
305 \startmode[letter]
306   \setuppapersize[letter][letter]
307   \setuplayout[%
308     backspace=44mm,
309     topspace=46mm,
310     height=199mm,
311     footer=10mm,
312     header=0pt, % no header
313     width=126mm]
314 \stopmode
315
316
317 % A4 imposed (A5), with no bc
318
319 \startmode[a4imposed]
320 % DIV=15 148 × 210: these are meant not to have binding correction,
321   % but just to play safe, let's say 1mm => 147x210
322   \setuppapersize[halfafour][halfafour]
323   \setuplayout[%
324     backspace=10.8mm, % 146/15 = 9.8 + 1
325     topspace=14mm, % 210/15 =  14
326     height=182mm, % 14 x 12 + 14 of the footer
327     footer=14mm, %
328     header=0pt, % no header
329     width=117.6mm] % 9.8 x 12
330 \stopmode
331
332 % A4 imposed (A5), with bc
333 \startmode[a4imposedbc]
334   \setuppapersize[halfafour][halfafour]
335   \setuplayout[% 14 mm was a bit too near to the spine, using the glue binding
336     backspace=17.3mm,  % 140/15 + 8 =
337     topspace=14mm, % 210/15 =  14
338     height=182mm, % 14 x 12 + 14 of the footer
339     footer=14mm, %
340     header=0pt, % no header
341     width=112mm] % 9.333 x 12
342 \stopmode
343
344
345 \startmode[letterimposedbc] % 139.7mm x 215.9 mm
346   \setuppapersize[halfletter][halfletter]
347   % DIV=15 8mm binding corr, => 132 x 216
348   \setuplayout[%
349     backspace=16.8mm, % 8.8 + 8
350     topspace=14.4mm, % 216/15 =  14.4
351     height=187.2mm, % 15.4 x 11 + 15 of the footer
352     footer=14.4mm, %
353     header=0pt, % no header
354     width=105.6mm] % 8.8 x 12
355 \stopmode
356
357 \startmode[letterimposed] % 139.7mm x 215.9 mm
358   \setuppapersize[halfletter][halfletter]
359   % DIV=15, 1mm binding correction. => 138.7x215.9
360   \setuplayout[%
361     backspace=10.3mm, % 9.24 + 1
362     topspace=14.4mm, % 216/15 =  14.4
363     height=187.2mm, % 15.4 x 11 + 15 of the footer
364     footer=14.4mm, %
365     header=0pt, % no header
366     width=111mm] % 9.24 x 12
367 \stopmode
368
369 %%% new formats for mini books
370 %%% \definepapersize[halfafive][width=105mm,height=148mm]
371
372 \startmode[a5imposed]
373 % DIV=12 105x148 : these are meant not to have binding correction,
374   % but just to play safe, let's say 1mm => 104x148
375   \setuppapersize[halfafive][halfafive]
376   \setuplayout[%
377     backspace=9.6mm,
378     topspace=12.3mm,
379     height=123.5mm, % 14 x 12 + 14 of the footer
380     footer=12.3mm, %
381     header=0pt, % no header
382     width=78.8mm] % 9.8 x 12
383 \stopmode
384
385 % A5 imposed (A6), with bc
386 \startmode[a5imposedbc]
387 % DIV=12 105x148 : with binding correction,
388   % let's say 8mm => 96x148
389   \setuppapersize[halfafive][halfafive]
390   \setuplayout[%
391     backspace=16mm,
392     topspace=12.3mm,
393     height=123.5mm, % 14 x 12 + 14 of the footer
394     footer=12.3mm, %
395     header=0pt, % no header
396     width=72mm] % 9.8 x 12
397 \stopmode
398
399 %%% \definepapersize[quarterletter][width=4.25in,height=5.5in]
400
401 % DIV=12 width=4.25in (108mm),height=5.5in (140mm) 
402 \startmode[halfletterimposed] % 107x140
403   \setuppapersize[quarterletter][quarterletter]
404   \setuplayout[%
405     backspace=10mm,
406     topspace=11.6mm,
407     height=116mm,
408     footer=11.6mm,
409     header=0pt, % no header
410     width=80mm] % 9.24 x 12
411 \stopmode
412
413 \startmode[halfletterimposedbc]
414   \setuppapersize[quarterletter][quarterletter]
415   \setuplayout[%
416     backspace=15.4mm,
417     topspace=11.6mm,
418     height=116mm,
419     footer=11.6mm,
420     header=0pt, % no header
421     width=76mm] % 9.24 x 12
422 \stopmode
423
424 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
425 %                            DOCUMENT BEGINS                                   %
426 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427
428 <% IF meta.lang %>
429 \mainlanguage[<%- meta.lang -%>]
430 <% ELSE %>
431 \mainlanguage[hr]
432 <% END %>
433
434 \starttext
435
436 <% IF texwantstoc %>
437
438 \placelist[awikipart,chapter,section,subsection]
439
440 <% END %>
441
442 \page[yes]
443