forked from Daniel-Diaz/HaTeX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Commands.hs
860 lines (687 loc) · 20.8 KB
/
Commands.hs
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
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
{-# LANGUAGE OverloadedStrings #-}
-- | LaTeX standard commands and environments.
module Text.LaTeX.Base.Commands
( -- * Basic functions
raw , between , comment , (%)
-- * Preamble commands
, title
, author
, date
, institute
, thanks
, documentclass
, usepackage
, linespread
-- ** Classes
-- *** Document classes
, article
, proc
, report
, minimal
, book
, slides
-- *** Class options
, ClassOption (..)
, customopt
, draft
, titlepage
, notitlepage
, onecolumn
, twocolumn
, oneside
, twoside
, landscape
, openright
, openany
, fleqn
, leqno
-- ** Paper sizes
, PaperType (..)
, a0paper
, a1paper
, a2paper
, a3paper
, a4paper
, a5paper
, a6paper
, b0paper
, b1paper
, b2paper
, b3paper
, b4paper
, b5paper
, b6paper
, letterpaper
, executivepaper
, legalpaper
-- ** Page styles
, pagestyle
, thispagestyle
, plain
, headings
, empty
, myheadings
, markboth
, markright
-- * Body commands
, document
, maketitle
-- ** Document structure
, tableofcontents
, abstract
, appendix
-- *** Sections
, part
, chapter
, section
, subsection
, subsubsection
, paragraph
, subparagraph
-- ** Logos & symbols
, today
, tex
, latex
, laTeX2
, laTeXe
, ldots
, vdots
, ddots
-- *** HaTeX specific
, hatex
, hatex3
, hatex_meta
, version
, hatex_version
-- ** Document layout
, par
, newline
, lnbk
, lnbk_
, newpage
, cleardoublepage
, clearpage
, linebreak
, nolinebreak
, pagebreak
, nopagebreak
, hspace
, hspace_
, vspace
, stretch
, smallskip
, bigskip
, indent
, noindent
-- *** Document measures
, textwidth
, linewidth
-- ** Formatting text
, verbatim
-- *** Fonts
--
-- Different font styles.
, textbf
, textit
, texttt
, textrm
, textsf
, textmd
, textup
, textsl
, textsc
, textnormal
, underline
, emph
-- *** Sizes
--
-- | Sizes are sorted from smallest to biggest.
, tiny
, scriptsize
, footnotesize
, small
, normalsize
, large
, large2
, large3
, huge
, huge2
-- ** Environments
, equation
, equation_
, enumerate
, itemize
, item
, flushleft
, flushright
, center
, quote
, verse
, cite
, description
, minipage
, figure
-- ** Page numbering
, pagenumbering
, arabic
, roman
, roman_
, alph
, alph_
-- ** Boxes
, mbox
, fbox
, parbox
, framebox
, makebox
, raisebox
, rule
-- * Cross references
, caption
, label
, ref
, pageref
-- ** Tables
, tabular
, (&)
, hline
, cline
-- ** Others
, footnote
, protect
, hyphenation
, hyp
, qts
) where
import Data.String
import Data.Maybe (catMaybes)
import Data.Text (toLower)
import Text.LaTeX.Base.Syntax
import Text.LaTeX.Base.Class
import Text.LaTeX.Base.Render
import Text.LaTeX.Base.Types
import Data.Version
import Data.List (intercalate)
--
import Paths_HaTeX
-- | Insert a raw piece of 'Text'.
-- This functions doesn't care about @LaTeX@ reserved characters,
-- it insert the text just as it is received.
raw :: LaTeXC l => Text -> l
raw = fromLaTeX . TeXRaw
-- | Calling 'between' @c l1 l2@ puts @c@ between @l1@ and @l2@ and
-- appends them.
between :: Monoid m => m -> m -> m -> m
between c l1 l2 = l1 <> c <> l2
-- | Create a comment.
comment :: LaTeXC l => Text -> l
comment = fromLaTeX . TeXComment
-- | This operator appends a comment after a expression.
-- For example:
--
-- > textbf "I'm just an example." % "Insert a few words here."
--
-- Since you are writing in Haskell, you may not need to output comments
-- as you can add them in the Haskell source. I added this feature
-- for completeness.
(%) :: LaTeXC l => l -> Text -> l
(%) l = (l <>) . comment
-- | Generate the title. It normally contains the 'title' name
-- of your document, the 'author'(s) and 'date'.
maketitle :: LaTeXC l => l
maketitle = comm0 "maketitle"
-- | Set the title of your document.
title :: LaTeXC l => l -> l
title = liftL $ \t -> TeXComm "title" [FixArg t]
-- | Set a date for your document.
date :: LaTeXC l => l -> l
date = liftL $ \t -> TeXComm "date" [FixArg t]
-- | Set the author(s) of the document.
author :: LaTeXC l => l -> l
author = liftL $ \t -> TeXComm "author" [FixArg t]
-- | Set either an institute or an organization
-- for the document.
institute :: LaTeXC l => Maybe l -> l -> l
institute Nothing = liftL $ \l -> TeXComm "institute" [FixArg l]
institute (Just s) = liftL2 (\l1 l2 -> TeXComm "institute" [OptArg l1,FixArg l2]) s
thanks :: LaTeXC l => l -> l
thanks = liftL $ \l -> TeXComm "thanks" [FixArg l]
-- | Import a package. First argument is a list of options for
-- the package named in the second argument.
usepackage :: LaTeXC l => [l] -> PackageName -> l
usepackage ls pn = liftListL (\ls -> TeXComm "usepackage" [MOptArg ls ,FixArg $ fromString pn]) ls
-- | The @LaTeX@ logo.
latex :: LaTeXC l => l
latex = comm0 "LaTeX"
-- | Start a new paragraph
par :: LaTeXC l => l
par = comm0 "par"
-- | Start a new line.
newline :: LaTeXC l => l
newline = comm0 "newline"
part :: LaTeXC l => l -> l
part = liftL $ \p -> TeXComm "part" [FixArg p]
chapter :: LaTeXC l => l -> l
chapter = liftL $ \c -> TeXComm "chapter" [FixArg c]
-- | Start a new section with a given title.
section :: LaTeXC l => l -> l
section = liftL $ \s -> TeXComm "section" [FixArg s]
subsection :: LaTeXC l => l -> l
subsection = liftL $ \sub -> TeXComm "subsection" [FixArg sub]
subsubsection :: LaTeXC l => l -> l
subsubsection = liftL $ \sub -> TeXComm "subsubsection" [FixArg sub]
paragraph :: LaTeXC l => l -> l
paragraph = liftL $ \p -> TeXComm "paragraph" [FixArg p]
subparagraph :: LaTeXC l => l -> l
subparagraph = liftL $ \p -> TeXComm "subparagraph" [FixArg p]
-- | Create the table of contents, automatically generated
-- from your 'section's, 'subsection's, and other related stuff.
tableofcontents :: LaTeXC l => l
tableofcontents = comm0 "tableofcontents"
appendix :: LaTeXC l => l
appendix = comm0 "appendix"
item :: LaTeXC l => Maybe l -> l
item Nothing = commS "item "
item (Just opt) = liftL (\opt -> TeXComm "item" [OptArg opt]) opt
equation :: LaTeXC l => l -> l
equation = liftL $ TeXEnv "equation" []
equation_ :: LaTeXC l => l -> l
equation_ = liftL $ TeXEnv "equation*" []
enumerate :: LaTeXC l => l -> l
enumerate = liftL $ TeXEnv "enumerate" []
itemize :: LaTeXC l => l -> l
itemize = liftL $ TeXEnv "itemize" []
description :: LaTeXC l => l -> l
description = liftL $ TeXEnv "description" []
flushleft :: LaTeXC l => l -> l
flushleft = liftL $ TeXEnv "flushleft" []
flushright :: LaTeXC l => l -> l
flushright = liftL $ TeXEnv "flushright" []
center :: LaTeXC l => l -> l
center = liftL $ TeXEnv "center" []
quote :: LaTeXC l => l -> l
quote = liftL $ TeXEnv "quote" []
verse :: LaTeXC l => l -> l
verse = liftL $ TeXEnv "verse" []
-- | Minipage environment.
minipage :: LaTeXC l =>
Maybe Pos -- ^ Optional position
-> l -- ^ Width
-> l -- ^ Minipage content
-> l
minipage Nothing = liftL2 $ \ts -> TeXEnv "minipage" [ FixArg ts ]
minipage (Just p) = liftL2 $ \ts -> TeXEnv "minipage" [ OptArg $ rendertex p , FixArg ts ]
-- | Figure environment.
figure :: LaTeXC l =>
Maybe Pos -- ^ Optional position
-> l -- ^ Figure content
-> l
figure Nothing = liftL $ TeXEnv "figure" []
figure (Just p) = liftL $ TeXEnv "figure" [ OptArg $ TeXRaw $ render p ]
abstract :: LaTeXC l => l -> l
abstract = liftL $ TeXEnv "abstract" []
cite :: LaTeXC l => l -> l
cite = liftL $ \l -> TeXComm "cite" [FixArg l]
-- Document class
-- | A class option to be passed to the 'documentclass' function.
data ClassOption =
Draft
| TitlePage
| NoTitlePage
| OneColumn
| TwoColumn
| OneSide
| TwoSide
| Landscape
| OpenRight
| OpenAny
| Fleqn
| Leqno
| FontSize Measure
| Paper PaperType
| CustomOption String
deriving Show
instance Render ClassOption where
render (FontSize m) = render m
render (Paper pt) = toLower (render pt) <> "paper"
render (CustomOption str) = fromString str
render co = toLower $ fromString $ show co
customopt :: String -> ClassOption
customopt = CustomOption
instance IsString ClassOption where
fromString = customopt
-- | LaTeX available paper types.
data PaperType =
A0 | A1 | A2 | A3 | A4 | A5 | A6
| B0 | B1 | B2 | B3 | B4 | B5 | B6
| Letter | Executive | Legal
deriving Show
instance Render PaperType where
-- | Set the document class. Needed in all documents.
documentclass :: LaTeXC l =>
[ClassOption] -- ^ Class options
-> ClassName -- ^ Class name
-> l
documentclass opts cn = fromLaTeX $ TeXComm "documentclass" [MOptArg $ fmap rendertex opts , FixArg $ fromString cn]
article :: ClassName
article = "article"
proc :: ClassName
proc = "proc"
minimal :: ClassName
minimal = "minimal"
report :: ClassName
report = "report"
book :: ClassName
book = "book"
slides :: ClassName
slides = "slides"
a0paper :: ClassOption
a0paper = Paper A0
a1paper :: ClassOption
a1paper = Paper A1
a2paper :: ClassOption
a2paper = Paper A2
a3paper :: ClassOption
a3paper = Paper A3
a4paper :: ClassOption
a4paper = Paper A4
a5paper :: ClassOption
a5paper = Paper A5
a6paper :: ClassOption
a6paper = Paper A6
b0paper :: ClassOption
b0paper = Paper B0
b1paper :: ClassOption
b1paper = Paper B1
b2paper :: ClassOption
b2paper = Paper B2
b3paper :: ClassOption
b3paper = Paper B3
b4paper :: ClassOption
b4paper = Paper B4
b5paper :: ClassOption
b5paper = Paper B5
b6paper :: ClassOption
b6paper = Paper B6
letterpaper :: ClassOption
letterpaper = Paper Letter
executivepaper :: ClassOption
executivepaper = Paper Executive
legalpaper :: ClassOption
legalpaper = Paper Legal
draft :: ClassOption
draft = Draft
-- | Typesets displayed formulae left-aligned instead of centred.
fleqn :: ClassOption
fleqn = Fleqn
-- | Places the numbering of formulae on the left hand side instead of the right.
leqno :: ClassOption
leqno = Leqno
titlepage :: ClassOption
titlepage = TitlePage
notitlepage :: ClassOption
notitlepage = NoTitlePage
onecolumn :: ClassOption
onecolumn = OneColumn
twocolumn :: ClassOption
twocolumn = TwoColumn
oneside :: ClassOption
oneside = OneSide
twoside :: ClassOption
twoside = TwoSide
-- | Changes the layout of the document to print in landscape mode
landscape :: ClassOption
landscape = Landscape
-- | Makes chapters begin either only on right hand pages
openright :: ClassOption
openright = OpenRight
-- | Makes chapters begin on the next page available.
openany :: ClassOption
openany = OpenAny
document :: LaTeXC l => l -> l
document = liftL $ TeXEnv "document" []
pagenumbering :: LaTeXC l => l -> l
pagenumbering = liftL $ \l -> TeXComm "pagenumbering" [FixArg l]
-- | Arabic numerals.
arabic :: LaTeXC l => l
arabic = fromLaTeX "arabic"
-- | Lowercase roman numerals.
roman :: LaTeXC l => l
roman = fromLaTeX "roman"
-- | Uppercase roman numerals.
roman_ :: LaTeXC l => l
roman_ = fromLaTeX "Roman"
-- | Lowercase letters.
alph :: LaTeXC l => l
alph = fromLaTeX "alph"
-- | Uppercase letters.
alph_ :: LaTeXC l => l
alph_ = fromLaTeX "Alph"
pagestyle :: LaTeXC l => l -> l
pagestyle = liftL $ \l -> TeXComm "pagestyle" [FixArg l]
thispagestyle :: LaTeX -> LaTeX
thispagestyle = liftL $ \l -> TeXComm "thispagestyle" [FixArg l]
plain :: LaTeXC l => l
plain = fromLaTeX "plain"
headings :: LaTeXC l => l
headings = fromLaTeX "headings"
empty :: LaTeXC l => l
empty = fromLaTeX "empty"
myheadings :: LaTeXC l => l
myheadings = fromLaTeX "myheadings"
-- | Used in conjunction with 'myheadings' for setting both the left and the right heading.
markboth :: LaTeXC l => l -> l -> l
markboth = liftL2 $ \l1 l2 -> TeXComm "markboth" [FixArg l1 , FixArg l2]
-- | Used in conjunction with 'myheadings' for setting the right heading.
markright :: LaTeXC l => l -> l
markright = liftL $ \l -> TeXComm "markright" [FixArg l]
-- | Start a new line. In a 'tabular', it starts a new row, so use 'newline' instead.
lnbk :: LaTeXC l => l
lnbk = fromLaTeX $ TeXNewLine False
lnbk_ :: LaTeXC l => l
lnbk_ = fromLaTeX $ TeXNewLine True
hyp :: LaTeXC l => l
hyp = fromLaTeX $ TeXCommS "-"
cleardoublepage :: LaTeXC l => l
cleardoublepage = comm0 "cleardoublepage"
clearpage :: LaTeXC l => l
clearpage = comm0 "clearpage"
newpage :: LaTeXC l => l
newpage = comm0 "newpage"
linebreak :: LaTeXC l => l -> l
linebreak = liftL $ \l -> TeXComm "linebreak" [OptArg l]
nolinebreak :: LaTeXC l => l -> l
nolinebreak = liftL $ \l -> TeXComm "nolinebreak" [OptArg l]
nopagebreak :: LaTeXC l => l -> l
nopagebreak = liftL $ \l -> TeXComm "nopagebreak" [OptArg l]
pagebreak :: LaTeXC l => l -> l
pagebreak = liftL $ \l -> TeXComm "pagebreak" [OptArg l]
hyphenation :: LaTeXC l => l -> l
hyphenation = liftL $ \l -> TeXComm "hyphenation" [FixArg l]
mbox :: LaTeXC l => l -> l
mbox = liftL $ \l -> TeXComm "mbox" [FixArg l]
fbox :: LaTeXC l => l -> l
fbox = liftL $ \l -> TeXComm "fbox" [FixArg l]
today :: LaTeXC l => l
today = comm0 "today"
tex :: LaTeXC l => l
tex = comm0 "TeX"
laTeX2 :: LaTeXC l => l
laTeX2 = comm0 "LaTeX"
laTeXe :: LaTeXC l => l
laTeXe = comm0 "LaTeXe"
-- | Horizontal dots.
ldots :: LaTeXC l => l
ldots = comm0 "ldots"
-- | Vertical dots.
vdots :: LaTeXC l => l
vdots = comm0 "vdots"
-- | Diagonal dots.
ddots :: LaTeXC l => l
ddots = comm0 "ddots"
-- | Quotation marks.
qts :: LaTeXC l => l -> l
qts l = between l (raw "``") (raw "''")
footnote :: LaTeXC l => l -> l
footnote = liftL $ \l -> TeXComm "footnote" [FixArg l]
linespread :: LaTeXC l => Float -> l
linespread x = fromLaTeX $ TeXComm "linespread" [FixArg $ rendertex x]
indent :: LaTeXC l => l
indent = comm0 "indent"
noindent :: LaTeXC l => l
noindent = comm0 "noindent"
hspace :: LaTeXC l => Measure -> l
hspace m = fromLaTeX $ TeXComm "hspace" [FixArg $ rendertex m]
hspace_ :: LaTeXC l => Measure -> l
hspace_ m = fromLaTeX $ TeXComm "hspace*" [FixArg $ rendertex m]
stretch :: LaTeXC l => Int -> l
stretch n = fromLaTeX $ TeXComm "stretch" [FixArg $ rendertex n]
vspace :: LaTeXC l => Measure -> l
vspace m = fromLaTeX $ TeXComm "vspace" [FixArg $ rendertex m]
protect :: LaTeXC l => l -> l
protect l = commS "protect" <> l
textwidth :: LaTeXC l => l
textwidth = comm0 "textwidth"
linewidth :: LaTeXC l => l
linewidth = comm0 "linewidth"
verbatim :: LaTeXC l => l -> l
verbatim = liftL $ TeXEnv "verbatim" []
underline :: LaTeXC l => l -> l
underline = liftL $ \l -> TeXComm "underline" [FixArg l]
emph :: LaTeXC l => l -> l
emph = liftL $ \l -> TeXComm "emph" [FixArg l]
textrm :: LaTeXC l => l -> l
textrm = liftL $ \l -> TeXComm "textrm" [FixArg l]
textsf :: LaTeXC l => l -> l
textsf = liftL $ \l -> TeXComm "textsf" [FixArg l]
-- | Set the given argument to monospaced font.
texttt :: LaTeXC l => l -> l
texttt = liftL $ \l -> TeXComm "texttt" [FixArg l]
textmd :: LaTeXC l => l -> l
textmd = liftL $ \l -> TeXComm "textmd" [FixArg l]
-- | Set the given argument to bold font face.
textbf :: LaTeXC l => l -> l
textbf = liftL $ \l -> TeXComm "textbf" [FixArg l]
textup :: LaTeXC l => l -> l
textup = liftL $ \l -> TeXComm "textup" [FixArg l]
-- Set the given argument to italic font face.
textit :: LaTeXC l => l -> l
textit = liftL $ \l -> TeXComm "textit" [FixArg l]
textsl :: LaTeXC l => l -> l
textsl = liftL $ \l -> TeXComm "textsl" [FixArg l]
-- | Set the given argument to small caps format.
textsc :: LaTeXC l => l -> l
textsc = liftL $ \l -> TeXComm "textsc" [FixArg l]
textnormal :: LaTeXC l => l -> l
textnormal = liftL $ \l -> TeXComm "textnormal" [FixArg l]
tiny :: LaTeXC l => l -> l
tiny = liftL $ \l -> TeXComm "tiny" [FixArg l]
scriptsize :: LaTeXC l => l -> l
scriptsize = liftL $ \l -> TeXComm "scriptsize" [FixArg l]
footnotesize :: LaTeXC l => l -> l
footnotesize = liftL $ \l -> TeXComm "footnotesize" [FixArg l]
small :: LaTeXC l => l -> l
small = liftL $ \l -> TeXComm "small" [FixArg l]
normalsize :: LaTeXC l => l -> l
normalsize = liftL $ \l -> TeXComm "normalsize" [FixArg l]
large :: LaTeXC l => l -> l
large = liftL $ \l -> TeXComm "large" [FixArg l]
large2 :: LaTeXC l => l -> l
large2 = liftL $ \l -> TeXComm "Large" [FixArg l]
large3 :: LaTeXC l => l -> l
large3 = liftL $ \l -> TeXComm "LARGE" [FixArg l]
huge :: LaTeXC l => l -> l
huge = liftL $ \l -> TeXComm "huge" [FixArg l]
huge2 :: LaTeXC l => l -> l
huge2 = liftL $ \l -> TeXComm "Huge" [FixArg l]
smallskip :: LaTeXC l => l
smallskip = comm0 "smallskip"
bigskip :: LaTeXC l => l
bigskip = comm0 "bigskip"
-- | The 'tabular' environment can be used to typeset tables with optional horizontal and vertical lines.
tabular :: LaTeXC l =>
Maybe Pos -- ^ This optional parameter can be used to specify the vertical position of the table.
-- Defaulted to 'Center'.
-> [TableSpec] -- ^ Table specification of columns and vertical lines.
-> l -- ^ Table content. See '&', 'lnbk', 'hline' and 'cline'.
-> l -- ^ Resulting table syntax.
tabular Nothing ts = liftL $ TeXEnv "tabular" [ FixArg $ TeXRaw $ renderAppend ts ]
tabular (Just p) ts = liftL $ TeXEnv "tabular" [ OptArg $ TeXRaw $ render p , FixArg $ TeXRaw $ renderAppend ts ]
-- | Column separator.
(&) :: LaTeXC l => l -> l -> l
(&) = liftL2 $ TeXOp "&"
-- | Horizontal line.
hline :: LaTeXC l => l
hline = commS "hline "
-- | @cline i j@ writes a partial horizontal line beginning in column @i@ and ending in column @j@.
cline :: LaTeXC l => Int -> Int -> l
cline i j = fromLaTeX $ TeXComm "cline" [ FixArg $ TeXRaw $ render i <> "-" <> render j ]
parbox :: LaTeXC l => Maybe Pos -> Measure -> l -> l
parbox Nothing w = liftL $ \t -> TeXComm "parbox" [ FixArg $ rendertex w , FixArg t ]
parbox (Just p) w = liftL $ \t -> TeXComm "parbox" [ OptArg $ TeXRaw $ render p
, FixArg $ TeXRaw $ render w
, FixArg t ]
makebox :: LaTeXC l => Maybe Measure -> Maybe Pos -> l -> l
makebox Nothing Nothing = liftL $ \t -> TeXComm "makebox" [ FixArg t ]
makebox (Just w) Nothing = liftL $ \t -> TeXComm "makebox" [ OptArg $ TeXRaw $ render w
, FixArg t ]
makebox Nothing (Just p) = liftL $ \t -> TeXComm "makebox" [ OptArg $ TeXRaw $ render p
, FixArg t ]
makebox (Just w) (Just p) = liftL $ \t -> TeXComm "makebox" [ OptArg $ TeXRaw $ render w
, OptArg $ TeXRaw $ render p
, FixArg t ]
framebox :: LaTeXC l => Maybe Measure -> Maybe Pos -> l -> l
framebox Nothing Nothing = liftL $ \t -> TeXComm "framebox" [ FixArg t ]
framebox (Just w) Nothing = liftL $ \t -> TeXComm "framebox" [ OptArg $ TeXRaw $ render w
, FixArg t ]
framebox Nothing (Just p) = liftL $ \t -> TeXComm "framebox" [ OptArg $ TeXRaw $ render p
, FixArg t ]
framebox (Just w) (Just p) = liftL $ \t -> TeXComm "framebox" [ OptArg $ TeXRaw $ render w
, OptArg $ TeXRaw $ render p
, FixArg t ]
raisebox :: LaTeXC l => Measure -> Maybe Measure -> Maybe Measure -> l -> l
raisebox m ma mb = liftL $ \l -> TeXComm "raisebox" $
[ FixArg $ rendertex m ]
++ fmap (OptArg . rendertex) (catMaybes [ma,mb])
++ [ FixArg l ]
-- | Produce a simple black box.
rule :: LaTeXC l =>
Maybe Measure -- ^ Optional lifting.
-> Measure -- ^ Width.
-> Measure -- ^ Height.
-> l
rule Nothing w h = fromLaTeX $ TeXComm "rule" [ FixArg $ TeXRaw $ render w
, FixArg $ TeXRaw $ render h ]
rule (Just l) w h = fromLaTeX $ TeXComm "rule" [ OptArg $ TeXRaw $ render l
, FixArg $ TeXRaw $ render w
, FixArg $ TeXRaw $ render h ]
-- HaTeX specific symbols
-- | Print the HaTeX logo.
hatex :: LaTeXC l => l
hatex = mbox $ "H"
<> hspace (Ex $ negate 0.3)
<> textsc "a"
<> hspace (Ex $ negate 0.3)
<> tex
-- | Print the HaTeX 3 logo.
hatex3 :: LaTeXC l => l
hatex3 = hatex <> emph (textbf "3")
-- | Print the HaTeX-meta logo.
hatex_meta :: LaTeXC l => l
hatex_meta = hatex <> emph (textsc "-meta")
-- | Print the HaTeX logo, beside the complete version number.
hatex_version :: LaTeXC l => l
hatex_version = hatex
<> emph (textbf $ rendertex x)
<> hspace (Ex $ negate 0.3)
<> emph ("." <> fromString (intercalate "." $ fmap show xs))
where
(x:xs) = versionBranch version
caption :: LaTeXC l => l -> l
caption = liftL $ \l -> TeXComm "caption" [FixArg l]
label :: LaTeXC l => l -> l
label = liftL $ \l -> TeXComm "label" [FixArg $ TeXRaw $ render l]
ref :: LaTeXC l => l -> l
ref = liftL $ \l -> TeXComm "ref" [FixArg $ TeXRaw $ render l]
pageref :: LaTeXC l => l -> l
pageref = liftL $ \l -> TeXComm "pageref" [FixArg $ TeXRaw $ render l]