-
Notifications
You must be signed in to change notification settings - Fork 0
/
libtlp.php
767 lines (661 loc) · 25.4 KB
/
libtlp.php
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
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
<?php
// library file for side-by-side-by-side Tractatus
// license: GPLv3
date_default_timezone_set('America/New_York');
function get_version_num() {
$cmd = 'cd "' . dirname(__FILE__) . '" && git tag | tail -n 1';
$vnum = trim(shell_exec($cmd));
if (substr($vnum, 0, 1) != 'v') {
$vnum = '[unknown]';
} else {
$vnum = substr($vnum,1);
}
return $vnum;
}
function unicodeize($s) {
$rv = $s;
$rv = mb_ereg_replace('\{\\\"a\}','ä', $rv);
$rv = mb_ereg_replace('\{\\\"o\}','ö', $rv);
$rv = mb_ereg_replace('\{\\\"u\}','ü', $rv);
$rv = mb_ereg_replace('\{\\\"U\}','Ü', $rv);
$rv = mb_ereg_replace('\{\\\"A\}','Ä', $rv);
$rv = mb_ereg_replace('\{\\\ss\}','ß', $rv);
$rv = mb_ereg_replace('\\\gdql\s*','„', $rv);
$rv = mb_ereg_replace('\{\\\gsql\}','‚', $rv);
$rv = mb_ereg_replace('\{\\\gsqr\}','‘', $rv);
$rv = mb_ereg_replace('\\\gdqr\{\}\s\s*','“ ', $rv);
$rv = mb_ereg_replace('\\\gdqr\{\}','“', $rv);
$rv = mb_ereg_replace('\\\gdqr','“', $rv);
$rv = mb_ereg_replace(' -- ',' – ', $rv);
$rv = mb_ereg_replace('([^-])---([^-])','\1—\2', $rv);
$rv = mb_ereg_replace('([^-])---$','\1—', $rv);
$rv = mb_ereg_replace('([0-9])--([0-9])','\1–\2', $rv);
$rv = mb_ereg_replace('``','“', $rv);
$rv = mb_ereg_replace('`','‘', $rv);
$rv = mb_ereg_replace('\'\'','”', $rv);
$rv = mb_ereg_replace('\'','’', $rv);
$rv = mb_ereg_replace('z\.\\\ B\.\\\ ','z.\\,B.\\ ', $rv);
$rv = mb_ereg_replace('z\.\\\ B\.','z.\\,B.', $rv);
$rv = mb_ereg_replace('z\.~B\.\\\ ','z.\\,B.\\ ', $rv);
$rv = mb_ereg_replace('z\.~B\.','z.\\,B.', $rv);
$rv = mb_ereg_replace('Z\.\\\ B\.\\\ ','Z.\\,B.\\ ', $rv);
$rv = mb_ereg_replace('Z\.\\\ B\.','Z.\\,B.', $rv);
$rv = mb_ereg_replace('U\.\\\ s\.\\\ w\.','U.\\,s.\\,w.', $rv);
$rv = mb_ereg_replace('\\\ldots','…', $rv);
$rv = mb_ereg_replace('\\\ae\{\}','æ', $rv);
$rv = mb_ereg_replace('\{\\\ae\}','æ', $rv);
return trim($rv);
}
function columns_preface() {
global $tlp,$settings;
$columns = 0;
foreach( array($settings->includeGerman, $settings->includeOgden, $settings->includePearsMcGuinness) as $v) {
if ($v) {
$columns++;
}
}
if ($columns == 0) {
return '';
}
$rv = '\\phantomsection\\addcontentsline{toc}{chapter}{Preface}\\section*{';
if ($settings->includeGerman) {
$rv .= 'Vorwort (Preface)';
} else {
$rv .= 'Preface';
}
$rv .= '}' . PHP_EOL;
$rv .= '\\begin{parcolumns}[sloppy,%' . PHP_EOL;
if ($settings->ruleBetweenColumns) {
$rv .= ' rulebetween,%' . PHP_EOL;
}
$rv .= ' distance=' . $settings->distanceBetweenColumns . '%' . PHP_EOL;
$rv .= ']{' . $columns . '}'. PHP_EOL;
// TABLE HEADER ROW
if ($settings->includeGerman) {
$rv .= '\\colchunk{\\negpbk\\textbf{German}\\\\~}' . PHP_EOL;
}
if ($settings->includeOgden) {
$rv .= '\\colchunk{\\negpbk\\textbf{Ogden}\\\\~}' . PHP_EOL;
}
if ($settings->includePearsMcGuinness) {
$rv .= '\\colchunk{\\negpbk\\textbf{Pears/McGuinness}\\\\~}' . PHP_EOL;
}
$rv .= '\\colplacechunks' . PHP_EOL;
foreach ($tlp as $pn => $a) {
//break after Preface
if (substr($pn,0,1) != "P") {
break;
}
if ($settings->includeGerman) {
$rv .= '\\colchunk{\\selectlanguage{german}';
$link_target = str_replace('P','pref',$pn);
$rv .= '\hypertarget{' . $link_target . '}{}';
$rv .= $a->German[0];
$rv .= '}' . PHP_EOL;
}
if ($settings->includeOgden) {
$rv .= '\\colchunk{\\selectlanguage{english}';
if (!($settings->includeGerman)) {
$link_target = str_replace('P','pref',$pn);
$rv .= '\hypertarget{' . $link_target . '}{}';
}
$rv .= $a->Ogden[0];
$rv .= '}' . PHP_EOL;
}
if ($settings->includePearsMcGuinness) {
$rv .= '\\colchunk{\\selectlanguage{english}';
if ((!($settings->includeGerman)) && (!($settings->includeOgden))) {
$link_target = str_replace('P','pref',$pn);
$rv .= '\hypertarget{' . $link_target . '}{}';
}
$rv .= $a->PearsMcGuinness[0];
$rv .= '}' . PHP_EOL;
}
$rv .= '\\colplacechunks' . PHP_EOL;
}
$rv .= '\\end{parcolumns}\\clearpage%' . PHP_EOL;
return $rv;
}
function version_abbreviation($version,$slash) {
if ($version == 'German') {
return 'GER';
}
if ($version == 'Ogden') {
return 'OGD';
}
if ($version == 'PearsMcGuinness') {
if ($slash) {
return 'P/M';
} else {
return 'PM';
}
}
return 'ERR';
}
function base_target($pn) {
if (substr($pn, 0, 1) == 'P') {
return 'pref' . substr($pn, 1);
}
return 'prop' . $pn;
}
function link_bracket_for($pn,$version,$anchor) {
global $settings;
$r = '';
$abbrev = version_abbreviation($version,false);
$base_target = base_target($pn);
if ($anchor) {
$r .= '\\hypertarget{' . $base_target . $abbrev;
if (!($settings->isLastPass)) {
$r .= '-' . $settings->currPassNum;
}
$r .= '}{';
}
$numvers = 0;
foreach(array($settings->includeGerman, $settings->includeOgden, $settings->includePearsMcGuinness) as $b) {
if ($b) { $numvers++; }
}
if (($numvers < 2) && ($version != 'index')) {
if ($anchor) {
$r .= '}';
return $r;
} else {
return '';
}
}
$r .= '\\textsf{';
if ($version != 'index') {
$r .= '\\scriptsize ';
$r .= version_abbreviation($version,true);
$r .= ' ';
} else {
$r .= '\\tiny ';
}
$r .= '[';
$numdone = 0;
if (($settings->includeGerman) && ($version != 'German')) {
$r .= '\\hyperlink{' . $base_target . version_abbreviation('German',false);
if (!($settings->isLastPass)) {
$r .= '-' . $settings->currPassNum;
}
$r .= '}{$\rightarrow$' . version_abbreviation('German',true) . '}';
$numdone++;
}
if (($settings->includeOgden) && ($version != 'Ogden')) {
if ($numdone > 0) {
$r .= ' | ';
}
$r .= '\\hyperlink{' . $base_target . version_abbreviation('Ogden',false);
if (!($settings->isLastPass)) {
$r .= '-' . $settings->currPassNum;
}
$r .= '}{';
if ($numdone == 0) {
$r.= '$\rightarrow$';
}
$r .= version_abbreviation('Ogden',true) . '}';
$numdone++;
}
if (($settings->includePearsMcGuinness) && ($version != 'PearsMcGuinness')) {
if ($numdone > 0) {
$r .= ' | ';
}
$r .= '\\hyperlink{' . $base_target . version_abbreviation('PearsMcGuinness',false);
if (!($settings->isLastPass)) {
$r .= '-' . $settings->currPassNum;
}
$r .= '}{';
if ($numdone == 0) {
$r.= '$\rightarrow$';
}
$r .= version_abbreviation('PearsMcGuinness',true) . '}';
}
$r .= ']}';
if ($anchor) {
$r .= '}';
}
return $r;
}
function standalone_preface($version) {
global $settings,$tlp;
if ($version == 'German') {
$identifier = 'Vorwort';
$short_identifier = $identifier;
if (($settings->includeOgden) || ($settings->includePearsMcGuinness)) {
$identifier .= ' (German preface)';
$short_identifier .= ' (Preface)';
}
}
if ($version == 'Ogden') {
$identifier = 'Preface';
$short_identifier = $identifier;
if (($settings->includeGerman) && (!($settings->includePearsMcGuinness))) {
$identifier .= ' (English)';
}
if ($settings->includePearsMcGuinness) {
$identifier .= ' (Ogden)';
}
}
if ($version == 'PearsMcGuinness') {
$identifier = 'Preface';
$short_identifier = $identifier;
if (($settings->includeGerman) && (!($settings->includeOgden))) {
$identifier .= ' (English)';
}
if ($settings->includeOgden) {
$identifier .= ' (Pears/McGuinness)';
}
}
$rv = '\\phantomsection\\addcontentsline{toc}{section}{' . $short_identifier . '}\\section*{' . $identifier . '}' . PHP_EOL;
foreach ($tlp as $pn => $a) {
//break after Preface
if (substr($pn,0,1) != "P") {
break;
}
if ($pn != 'P9') {
$rv .= '\\noindent ';
$rv .= link_bracket_for($pn,$version,true) . PHP_EOL . PHP_EOL;
}
$rv .= $a->{$version}[0] . PHP_EOL . PHP_EOL;
}
$rv .= '\\clearpage%' . PHP_EOL;
return $rv;
}
function prop_one_footnote_text_for_version($version) {
if ($version == 'German') {
return 'Die Decimalzahlen als Nummern der einzelnen Sätze deuten das logische Gewicht der Sätze an, den Nachdruck, der auf ihnen in meiner Darstellung liegt. Die Sätze $n.1,\\thickspace n.2,\\thickspace n.3,$ etc., sind Bemerkungen zum Satze No.\\ $n$; die Sätze $n.m1,\\thickspace n.m2,$ etc.\\ Bemerkungen zum Satze No.\\ $n.m$; und so weiter.';
}
if ($version == 'Ogden') {
return 'The decimal figures as numbers of the separate propositions indicate the logical importance of the propositions, the emphasis laid upon them in my exposition. The propositions $n.1,\\thickspace n.2,\\thickspace n.3,$ etc., are comments on proposition No.\\ $n$; the propositions $n.m1,\\thickspace n.m2,$ etc., are comments on the proposition No.\\ $n.m$; and so on.';
}
return 'The decimal numbers assigned to the individual propositions indicate the logical importance of the propositions, the stress laid on them in my exposition. The propositions $n.1,\\thickspace n.2,\\thickspace n.3,$ etc.\\ are comments on proposition no. $n$; the propositions $n.m1,\\thickspace n.m2,$ etc.\\ are comments on proposition no. $n.m$; and so on.';
}
function proposition_one_footnote_text() {
global $settings;
$r = '\\renewcommand{\\thefootnote}{}' . PHP_EOL;
$r .= '\\footnotetext{* ';
if ($settings->includeGerman) {
$r .= '\\kckaddition{[German]} ' . prop_one_footnote_text_for_version('German');
if (($settings->includeOgden) || ($settings->includePearsMcGuinness)) {
$r .= '\\ / ';
}
}
if ($settings->includeOgden) {
$r .= '\\kckaddition{[Ogden]} ' . prop_one_footnote_text_for_version('Ogden');
if ($settings->includePearsMcGuinness) {
$r .= '\\ / ';
}
}
if ($settings->includePearsMcGuinness) {
$r .= '\\kckaddition{[Pears \\& McGuinness]} ' . prop_one_footnote_text_for_version('PearsMcGuinness');
}
$r .= '}' . PHP_EOL;
return $r;
}
function start_col_environment($columns,$rulebetween,$dist) {
$r = '\\begin{parcolumns}[sloppy,%' . PHP_EOL;
if ($rulebetween) {
$r .= ' rulebetween,%' . PHP_EOL;
}
$r .= ' distance=' . $dist . ',%' . PHP_EOL;
$r .= ' colwidths={1={\\pnmaxwidth}}%' . PHP_EOL;
$r .= ']{' . ($columns+1) . '}' . PHP_EOL;
return $r;
}
function end_col_environment() {
return '\\end{parcolumns}%' . PHP_EOL ;
}
function br_footnote_text($mark) {
$r = '\\footnotetext{* ';
if ($mark) {
$r .= '\\kckaddition{[Ogden only]} ';
}
$r .= '\\emph{I.e.}\\ not the form of one particular law, but of any law of a certain sort (B.\\,R.).}' . PHP_EOL;
return $r;
}
function depth_of($s) {
$p = str_replace('.','',$s);
$d = (strlen($p) - 1);
return $d;
}
function multicolumn_version() {
global $tlp,$settings;
// handle preface if necessary
if ($settings->includePreface) {
echo columns_preface();
}
// count columns
$columns = 0;
foreach( array($settings->includeGerman, $settings->includeOgden, $settings->includePearsMcGuinness) as $v) {
if ($v) {
$columns++;
}
}
if ($columns == 0) {
echo 'No versions selected!';
return;
}
// title header
echo '\\phantomsection\\addcontentsline{toc}{chapter}{Tractatus Logico-Philosophicus}\\section*{Tractatus Logico-Philosophicus}' . PHP_EOL;
// PASSES LOOP START
for ($passnum = 0; $passnum<count($settings->passes); $passnum++) {
$settings->thisPass = $settings->passes[$passnum];
$settings->isLastPass = (($passnum+1) == count($settings->passes));
$settings->currPassNum = $passnum;
// depth level indicator
if ($settings->useDepthMarkers) {
echo PHP_EOL . PHP_EOL;
if ($settings->thisPass->maxDepth > $settings->thisPass->minDepth) {
echo '\\noindent\\hrulefill\ \textsf{[depth levels ' . $settings->thisPass->minDepth . '–' . $settings->thisPass->maxDepth . ']}';
} else {
echo '\\noindent\\hrulefill\ \textsf{[depth level ' . $settings->thisPass->minDepth . ']}';
}
echo PHP_EOL . PHP_EOL;
} else {
if ($passnum != 0) {
echo PHP_EOL . PHP_EOL . '\\bigskip' . PHP_EOL . PHP_EOL;
}
}
// footnote on section 1
if (($settings->thisPass->minDepth == 0) && ($settings->thisPass->startProposition == "1") && (!($settings->fnDone)) ) {
echo proposition_one_footnote_text();
$settings->fnDone = true;
}
// have latex determine width of widest label
if ($passnum == 0) {
echo '\\newlength{\\pnmaxwidth}%' . PHP_EOL . '\\setlength{\\pnmaxwidth}{\\widthof{\\textbf{2.02331}}}%' . PHP_EOL;
}
// start columns
echo start_col_environment($columns, $settings->ruleBetweenColumns, $settings->distanceBetweenColumns);
// TABLE HEADER ROW
echo '\\colchunk{}' . PHP_EOL;
if ($settings->includeGerman) {
echo '\\colchunk{\\negpbk\\textbf{German}\\\\~}' . PHP_EOL;
}
if ($settings->includeOgden) {
echo '\\colchunk{\\negpbk\\textbf{Ogden}\\\\~}' . PHP_EOL;
}
if ($settings->includePearsMcGuinness) {
echo '\\colchunk{\\negpbk\\textbf{Pears/McGuinness}\\\\~}' . PHP_EOL;
}
echo '\\colplacechunks' . PHP_EOL;
// MAIN LOOP THROUGH TLP PROPOSITIONS
$reached_starting_prop = false;
$reached_ending_prop = false;
foreach ($tlp as $pn => $ptext) {
// see if reached starting proposition; if not, go to next proposition
// this should also skip the Preface
if (!($reached_starting_prop)) {
if ($pn == $settings->thisPass->startProposition) {
$reached_starting_prop = true;
} else {
continue;
}
}
// check if depth is within range of current settings
$pndepth = depth_of($pn);
if (($pndepth < $settings->thisPass->minDepth) || ($pndepth > $settings->thisPass->maxDepth)) {
if ($pn == $settings->thisPass->endProposition) {
$reached_ending_prop = true;
break;
} else {
continue;
}
}
// loop through paragraphs in proposition
for ($i=0; $i<count($ptext->German); $i++) {
// first column in row, for prop number
if ($i==0) {
echo '\\colchunk{\\negpbk\\hypertarget{prop';
echo $pn;
if (!($settings->isLastPass)) {
echo '-' . $settings->currPassNum;
}
echo '}{\\textbf{';
echo $pn;
if ($pn == '1') { echo '*'; }
echo '}}}' . PHP_EOL;
} else {
echo '\\colchunk{}' . PHP_EOL;
}
//German column
if ($settings->includeGerman) {
echo '\\colchunk{\\selectlanguage{german}';
echo $ptext->German[$i];
echo '}' . PHP_EOL;
}
//Ogden column
if ($settings->includeOgden) {
echo '\\colchunk{\\selectlanguage{english}';
echo $ptext->Ogden[$i];
echo '}' . PHP_EOL;
}
//Pears/McGuinness column
if ($settings->includePearsMcGuinness) {
echo '\\colchunk{\\selectlanguage{english}';
echo $ptext->PearsMcGuinness[$i];
echo '}' . PHP_EOL;
}
echo '\\colplacechunks' . PHP_EOL;
}
// check if footnote for 6.32 needed
if (($pn == '6.32') && ($settings->includeOgden)) {
echo end_col_environment();
echo br_footnote_text(true);
echo start_col_environment($columns, $settings->ruleBetweenColumns, $settings->distanceBetweenColumns);
}
// check if ending proposition; if so, break loop
if ($pn == $settings->thisPass->endProposition) {
$reached_ending_prop = true;
break;
}
}
// finish column block
echo end_col_environment();
} // PASSES LOOP END
}
function index_link_for($s) {
global $settings;
if (mb_ereg_match('.*–', $s)) {
$parts = explode('–',$s,2);
return index_link_for($parts[0]) . '–' . index_link_for($parts[1]);
}
if (substr($s, 0, 1) == 'P') {
$targ = mb_ereg_replace('P','pref',$s);
if ($settings->includePreface) {
if ($settings->multicolumnLayout) {
return '\\hyperlink{' . $targ . '}{' . $s . '}';
} else {
return $s . ' ' . link_bracket_for($s, 'index', false);
}
} else {
return $s;
}
}
$d = depth_of($s);
if (($d < $settings->thisPass->minDepth) || ($d > $settings->thisPass->maxDepth)) {
return $s;
}
if ($settings->multicolumnLayout) {
return '\\hyperlink{prop' . $s . '}{' . $s . '}';
}
return $s . ' ' . link_bracket_for($s, 'index', false);
}
function insert_index() {
$ind_entries = json_decode(file_get_contents(dirname(__FILE__) . '/tlp_index.json'));
if (!(is_array($ind_entries))) {
echo '\\indexentry{Failed to decode index JSON file.}';
return;
}
$start_letter = 'a';
foreach ($ind_entries as $e) {
// check if new first letter
if (!($e->isSubEntry)) {
if ( substr($e->entryname, 0, 8) == '\\textit{' ) {
$this_first_letter = strtolower( substr($e->entryname, 8, 1) );
} else {
$this_first_letter = strtolower( substr($e->entryname, 0, 1) );
}
if ($this_first_letter != $start_letter) {
$start_letter = $this_first_letter;
echo PHP_EOL . '\\indexgap' . PHP_EOL . PHP_EOL;
}
}
// type of entry
if ($e->isSubSubEntry) {
echo ' \indexsubsubentry{';
} else {
if ($e->isSubEntry) {
echo ' \indexsubentry{';
} else {
echo '\indexentry{';
}
}
echo $e->entryname;
if ((isset($e->cf)) || (isset($e->refs))) {
echo ', ';
}
if (isset($e->cf)) {
echo 'cf.\\ ' . $e->cf . '.';
}
if (isset($e->refs)) {
for ($i=0; $i<count($e->refs); $i++) {
$r = $e->refs[$i];
echo index_link_for($r->target);
if (isset($r->aftertext)) {
if (!(substr($r->aftertext, 0, 1) == ';')) {
echo ' ';
}
echo $r->aftertext . ' ';
} else {
if (($i+1) != count($e->refs)) {
echo ', ';
}
}
}
}
echo '}' . PHP_EOL;
}
}
function standalone_version($version) {
global $settings,$tlp;
$booktitle = 'Tractatus Logico-Philosophicus';
$toc_line = 'English translation';
$title_header = $booktitle;
if ($version=='German') {
echo '\\selectlanguage{german}%' . PHP_EOL;
$booktitle = 'Logisch-philosophische Abhandlung';
$title_header = $booktitle;
$toc_line = 'German text';
if (($settings->includeOgden) || ($settings->includePearsMcGuinness)) {
$title_header = $booktitle . ' (German text)';
}
}
if ($version=='Ogden') {
echo '\\selectlanguage{english}%' . PHP_EOL;
$toc_line .= ' (Ogden)';
if ($settings->includePearsMcGuinness) {
$toc_line = 'Ogden translation';
}
if (($settings->includeGerman) || ($settings->includePearsMcGuinness)) {
$title_header .= ' (Ogden translation)';
}
}
if ($version=='PearsMcGuinness') {
echo '\\selectlanguage{english}%' . PHP_EOL;
$toc_line .= ' (Pears/McGuinness)';
if ($settings->includeOgden) {
$toc_line = 'Pears/McGuinness translation';
}
if (($settings->includeGerman) || ($settings->includeOgden)) {
$title_header .= ' (Pears/McGuinness translation)';
}
}
// toc category listing
echo '\\clearpage\\phantomsection\\addcontentsline{toc}{chapter}{' . $toc_line . '}%' . PHP_EOL;
// preface
if ($settings->includePreface) {
echo standalone_preface($version);
}
// header and toc entry
echo '\\phantomsection\\addcontentsline{toc}{section}{' . $booktitle . '}\\section*{\raggedright ' . $title_header . '}%' . PHP_EOL;
// PASSES LOOP
$settings->fnDone = false;
for ($passnum = 0; $passnum<count($settings->passes); $passnum++) {
$settings->thisPass = $settings->passes[$passnum];
$settings->isLastPass = (($passnum+1) == count($settings->passes));
$settings->currPassNum = $passnum;
// depth level indicator
if ($settings->useDepthMarkers) {
echo PHP_EOL . PHP_EOL;
if ($settings->thisPass->maxDepth > $settings->thisPass->minDepth) {
echo '\\noindent\\hrulefill\ \\textsf{[depth levels ' . $settings->thisPass->minDepth . '–' . $settings->thisPass->maxDepth . ']}';
} else {
echo '\\noindent\\hrulefill\ \\textsf{[depth level ' . $settings->thisPass->minDepth . ']}';
}
echo PHP_EOL . PHP_EOL;
} else {
if ($passnum != 0) {
echo PHP_EOL . PHP_EOL . '\\bigskip' . PHP_EOL . PHP_EOL;
}
}
//footnote on prop1
if (($settings->thisPass->minDepth == 0) && ($settings->thisPass->startProposition == "1") && (!($settings->fnDone)) ) {
echo '\\renewcommand{\\thefootnote}{}%' . PHP_EOL . '\\footnotetext{* ' . prop_one_footnote_text_for_version($version) . '}%' . PHP_EOL;
$settings->fnDone = true;
}
// MAIN LOOP THROUGH TLP PROPOSITIONS
$reached_starting_prop = false;
$reached_ending_prop = false;
foreach ($tlp as $pn => $ptext) {
// see if reached starting proposition; if not, go to next proposition
// this should also skip the Preface
if (!($reached_starting_prop)) {
if ($pn == $settings->thisPass->startProposition) {
$reached_starting_prop = true;
} else {
continue;
}
}
// check if depth is within range of current settings
$pndepth = depth_of($pn);
if (($pndepth < $settings->thisPass->minDepth) || ($pndepth > $settings->thisPass->maxDepth)) {
if ($pn == $settings->thisPass->endProposition) {
$reached_ending_prop = true;
break;
} else {
continue;
}
}
// prop num marker
echo '\\noindent\\textbf{' . $pn;
if ($pn == '1') { echo '*'; }
echo '} ';
echo link_bracket_for($pn,$version,true);
echo PHP_EOL . PHP_EOL;
// loop through paragraphs in proposition
for ($i=0; $i<count($ptext->{$version}); $i++) {
echo '{' . $ptext->{$version}[$i] ;
// insert footnote
if (($pn == '6.32') && ($version=='Ogden')) {
echo br_footnote_text(false);
}
echo '\\par}' . PHP_EOL . PHP_EOL;
}
// check if ending proposition; if so, break loop
if ($pn == $settings->thisPass->endProposition) {
$reached_ending_prop = true;
break;
}
}
} // end passes loop
}
function german_standalone_version() {
standalone_version('German');
}
function ogden_standalone_version() {
standalone_version('Ogden');
}
function pmc_standalone_version() {
standalone_version('PearsMcGuinness');
}
?>