module Latex:sig
..end
type
t
typesize =
[ `Baselineskip of float
| `Baselinestretch of float
| `Bp of float
| `Cc of float
| `Cm of float
| `Dd of float
| `Em of float
| `Ex of float
| `Fill
| `In of float
| `Linewidth of float
| `Mm of float
| `Parindent of float
| `Parskip of float
| `Pc of float
| `Pt of float
| `Sp of float
| `Stretch of int
| `Textheight of float
| `Textwidth of float
| `Unitlength of float ]
`In
: inches`Mm
: millimeters`Cm
: centimeters`Pt
: points (about 1/72 inch)`Em
: approximately the width of an "M" in the current font`Ex
: approximately the width of an "x" in the current font`Pc
: pica (12pt/pc)`Bp
: big pt (72bp/in)`Dd
: didot (1157dd=1238pt)`Cc
: cicero (12dd/cc)`Sp
: scaled point (65536sp/pt)`Parindent
: normal paragraph indentation`Baselineskip
: normal vertical distance between lines in a paragraph`Baselinestretch
: multiplies `Baselineskip
`Parskip
: the extra vertical space between paragraphs`Textwidth
: the width of text on the page`Linewidth
: width of a line in the local environment`Textheight
: the height of text on the page`Unitlength
: units of length in picture environment`Fill
: rubber length; takes as much space as possible`Stretch
: rubber length; if multiple `Stretch
-sized commands are issued
on the same line (or vertical box) they stretch in proportion of their respective
factor.val latex_of_size : size -> t
typedocumentclass =
[ `Article
| `Beamer
| `Book
| `Custom of string
| `Letter
| `Report
| `Slides ]
typedocumentoptions =
[ `A4paper | `Landscape | `Pt of int | `TwoColumn ]
val document : ?documentclass:documentclass ->
?options:documentoptions list ->
?title:t ->
?author:t ->
?date:t ->
?prelude:t -> ?packages:(t * t) list -> t -> t
~packages
argument takes a list of (name, opt)
where name
is the
name of the package and opt
is its option. This is equivalent to
using several calls to usepackage
in the ~prelude
.
The two basic operations on variables are get
and setf
.
get
outputs an ast depending on the current contents of a
variable.
setf
updates the contents of a variable.
get
can also use the contents of a variable at a different
position in the document.
To use a position, you need to declare one first with
position
. then you can place that position in you document with
place
. You must not place a position more than one time.
If a position isn't placed, the contents of the variables at that
position will be the default one.
The final contents of variables is obtained by a fixpoint
computation wich is performed by the printing functions
Latex.to_buffer
, Latex.to_channel
, Latex.to_file
, Latex.to_string
. That
fixpoint may not terminate. In that case, the log will tell you which
variable did not converge.
type 'a
variable
val variable : ?eq:('a -> 'a -> bool) ->
?name:string -> ?printer:('a -> string) -> 'a -> 'a variable
eq
is the equality function on the type of the variable. Default is =
.
name
and printer
are used to print information when the
fixpoint calculation diverged.
val setf : 'a variable -> ('a -> 'a) -> t
val setf2 : 'a variable -> 'b variable -> ('a -> 'b -> 'b) -> t
setf var_in var_out f
Change the value of the variable var_out
in the rest of the document
using the contents of var_in
.type
position
val position : ?name:string -> unit -> position
name
is used to print information when the fixpoint computation
diverged.val place : position -> t
val get : ?position:position -> 'a variable -> ('a -> t) -> t
get
has no parameter position
then the current value of the
variable is taken. Otherwise it is the value at position
.val set : 'a variable -> 'a -> t
set x v
: return a node which, when evaluated, changes the contents
of variable x
to value v
.
val final : 'a variable -> ('a -> t) -> t
get
, but the value of the variable is taken at the end of
the document.val incr_var : int variable -> t
incr_var x
is equivalent to setf x (fun x -> x + 1)
.
val decr_var : int variable -> t
decr_var x
is equivalent to setf x (fun x -> x - 1)
.
val vari : int variable -> t
vari x
is equivalent to get x (fun x -> text (string_of_int x))
.
val varf : float variable -> t
varf x
is equivalent to get x (fun x -> text (string_of_float x))
.
val varb : bool variable -> t
varb x
is equivalent to get x (fun x -> text (string_of_bool x))
.
val vars : string variable -> t
vars x
is equivalent to get x text
.
val vart : t variable -> t
vart x
is equivalent to get x (fun x -> x)
.
val finali : int variable -> t
finali x
is equivalent to final x (fun x -> text (string_of_int x))
.
val finalf : float variable -> t
finalf x
is equivalent to final x (fun x -> text (string_of_float x))
.
val finalb : bool variable -> t
finalb x
is equivalent to final x (fun x -> text (string_of_bool x))
.
val finals : string variable -> t
finals x
is equivalent to final x text
.
val finalt : t variable -> t
finalt x
is equivalent to final x (fun x -> x)
.
let lbl_intro = label ()
let intro = section ~label: lbl_intro "This is Section~{ref_ lbl_intro}."
type
label
val label : ?name:string -> unit -> label
Argument name
can be used to force the name of the label in the
LaTeX file. This can be useful if you need to refer to this label in
an external LaTeX file or if the label itself is declared in another
LaTeX file. The default value of name
is "latex_lib_label_n"
where
n
is a counter.
val ref_ : label -> t
typefloat_position =
[ `B | `Force | `H | `P | `T ]
`H
: here`T
: top of page`B
: bottom of page`P
: put on a special page for floats only`Force
: override internal LaTeX parametersval float_all : float_position list
[ `H; `T; `B; `P ]
val figure : ?label:label ->
?pos:float_position list ->
?center:bool ->
?side_caption:bool -> ?caption:t -> ?wide:bool -> t -> t
Default value for center
is false.
If side_caption
is true
, the caption will be placed at the side of
the figure instead of at the bottom. This uses package sidecap
.
Default value is false
.
Argument ~wide: true
must be used for multi-columns documents if you
want the figure to use the full width of the page. In this case,
positions `H
has no effect, and position `B
adds package
stfloats
.
To prevent wide figures from being placed out-of-order with respect to
their "non-wide" counterparts, use package fixltx2e
.
typewrapfigure_position =
[ `Force of [ `I | `L | `O | `R ] | `I | `L | `O | `R ]
wrapfig
.`L
: left`R
: right`I
: inside (if document is twosided)`O
: outside (if document is twosided)`Force _
: force the figure to start precisely where specified
(may cause it to run over page breaks)val wrapfigure : ?label:label ->
?pos:wrapfigure_position ->
?lines:int ->
?width:size -> ?center:bool -> ?caption:t -> t -> t
Uses package wrapfig
.
Argument lines
specifies the height of the figure in number of lines.
It can be useful if LaTeX fails to compute it correctly.
Default value for width
is half the text width.
Default value for center
is false.
If there is too much space on top and below the figure, and lines
does
not do what you want, you can add
some negative vspace
s. In general it is better to let
LaTeX place the figure for you, though.
typefloatingfigure_position =
[ `L | `P | `R ]
floatflt
.`L
: left`R
: right`P
: right if the pagenumber is odd, left if evenval floatingfigure : ?label:label ->
?pos:floatingfigure_position ->
?width:size -> ?center:bool -> ?caption:t -> t -> t
Uses package floatflt
.
Default value for width
is half the text width.
Default value for center
is false.
val subfloat : ?label:label -> ?caption:t -> t -> t
Uses package subfig
.
Use it inside a figure
to insert sub-figures.
val hyphen : t
val index : t -> t -> t
index x y
produces {x}_{y}
val exponent : t -> t -> t
exponent x y
produces {x}^{y}
val index_exponent : t -> t -> t -> t
index_exponent x y z
produces {x}_{y}^{z}
.
This is NOT equivalent to exponent (index x y) z
as this would
produce {{x}_{y}}^{z}
. The former allows the exponent to be printed
above the index, while the latter does not.
val tableofcontents : t
val listoffigures : t
val listoftables : t
val appendix : t
val place_index : t -> t
printindex
output an index listing the various point which have
been referenced by place_index key
. key
can be a phrase
in which case it appears as-is in the index, or some more complex
instruction (documentation for index
keys can be found in the Not So Short Introduction to Latex (available
online) or the Latex Companion).
If you use at least one of place_index
or printindex
, a file .idx
will be produced at the same time as the .aux. It needs to be processed
by the program makeindex (makeindex file.idx). Then (pdf)latex
needs to be run again.
val printindex : t
val today : t
val maketitle : t
val part : ?label:label -> t -> t
val chapter : ?label:label -> ?short:t -> t -> t
val section : ?label:label -> ?short:t -> t -> t
val subsection : ?label:label -> ?short:t -> t -> t
val subsubsection : ?label:label -> ?short:t -> t -> t
val paragraph : t -> t
val chapter' : ?label:label -> ?short:t -> t -> t
chapter
but with no numbering.val section' : ?label:label -> ?short:t -> t -> t
section
but with no numbering.val subsection' : ?label:label -> ?short:t -> t -> t
subsection
but with no numbering.val subsubsection' : ?label:label -> ?short:t -> t -> t
subsubsection
but with no numbering.val par : t
val displaymath : t -> t
val equation : ?label:label -> t -> t
val hfill : t
val vfill : t
val vfil : t
val footnote : t -> t
val latex_of_int : int -> t
val latex_of_float : float -> t
val itemize : t list -> t
val enumerate : t list -> t
val newline : t
val newline_size : size -> t
val newpage : t
val clearpage : t
newpage
, but also force figures and tables floating in the
current page to be printed.val noindent : t
val space : t
val quad : t
val qquad : t
val includegraphics : t -> t
val symbol : int -> t
val symbolc : char -> t
char
into an int
and apply symbol
.val center : t -> t
val flushleft : t -> t
val flushright : t -> t
val quote : t -> t
val quotation : t -> t
val stackrel : t -> t -> t
val vspace : size -> t
val hspace : size -> t
val addvspace : size -> t
vspace
, but an addvspace x
followed by an addvspace y
will produce an addvspace
of max x y
.val ignorespaces : t
val smallskip : t
vspace
.val medskip : t
vspace
.val bigskip : t
vspace
.val nointerlineskip : t
val phantom : t -> t
val vphantom : t -> t
val hphantom : t -> t
val rule_ : ?lift:size -> size -> size -> t
rule_ width height
draws a rule (i.e. a black box) of width width
and height height
(for instance a horizontal or vertical line).
The optional argument lift
moves the rule up if positive and down
if negative.
A special case is when width
is null. In this case the rule,
called a strut, does not display, it only makes sure that the
surrounding box has at least its height.typevalignment =
[ `B | `C | `T ]
val parbox : size -> ?valign:valignment -> t -> t
valign
optional argument controls the vertical alignment of
the box with respect to the surrounding text.val minipage : size -> ?valign:valignment -> t -> t
parbox
.typehalignment =
[ `C | `L | `R | `S ]
typexsize =
[ `Baselineskip of float
| `Baselinestretch of float
| `Bp of float
| `Cc of float
| `Cm of float
| `Dd of float
| `Depth of float
| `Em of float
| `Ex of float
| `Fill
| `Height of float
| `In of float
| `Linewidth of float
| `Mm of float
| `Parindent of float
| `Parskip of float
| `Pc of float
| `Pt of float
| `Sp of float
| `Stretch of int
| `Textheight of float
| `Textwidth of float
| `Totalheight of float
| `Unitlength of float
| `Width of float ]
Latex.makebox
, Latex.framebox
and Latex.raisebox
)
can use extra size information in their definition. These are computed
from their content:
`Width
is the width of the content
`Height
is the height above the baseline
`Depth
is the height below the baseline
`Totalheight
is the sum of `Height
and `Depth
val makebox : xsize -> ?halign:halignment -> t -> t
val framebox : xsize -> ?halign:halignment -> t -> t
makebox
but draws a frame around the box.val raisebox : shift:xsize ->
?fakeheight:xsize * xsize -> t -> t
raisebox ~shift x
displays x vertically displaced by shift
.
If ~fakeheight
is not specified, then the line is built as if
x
had not been moved.
If ~fakeheight:(h,d)
then the line building algorithm sees a box
which extends h
above the baseline (height) and d
below the
baseline (depth).typealignment =
[ `C | `L | `R ]
typearray_column =
[ `C | `L | `R | `Sep of t | `Vert ]
type
array_line
val array : ?valign:valignment ->
array_column list -> array_line list -> t
val array_line : ?sep:size ->
?layout:(int * [ `C | `I | `L | `R ]) list ->
t list -> array_line
`I
in layout means that the column inherits the alignment
of the first corresponding column in the array layout.
The integers in the layout correspond to over how many of the array's column
will the cell will span.val array_command : t -> array_line
array_command x
is a low level command. It gives x
as an array line to Latex.
Meant to define alternative commands to draw horizontal lines in arrays.val frontmatter : t
val backmatter : t
val mainmatter : t
val underbrace : t -> t -> t
val overbrace : t -> t -> t
val emph : t -> t
val texttt : t -> t
val textsc : t -> t
val textit : t -> t
val textbf : t -> t
val textrm : t -> t
val textsf : t -> t
val mathit : t -> t
val mathbf : t -> t
val mathrm : t -> t
val mathsf : t -> t
val mathcal : t -> t
val tiny : t -> t
val scriptsize : t -> t
val footnotesize : t -> t
val small : t -> t
val normalsize : t -> t
val large : t -> t
val large2 : t -> t
val large3 : t -> t
val huge : t -> t
val huge2 : t -> t
val hat : t -> t
val grave : t -> t
val bar : t -> t
val acute : t -> t
val mathring : t -> t
val check : t -> t
val dot : t -> t
val vec : t -> t
val breve : t -> t
val tilde : t -> t
val ddot : t -> t
val widehat : t -> t
hat
which spreads over the whole argument.val widetilde : t -> t
tilde
which spreads over the whole argument.val overline : t -> t
bar
which spreads over the whole argument.val alpha : t
val beta : t
val gamma : t
val delta : t
val epsilon : t
val varepsilon : t
val zeta : t
val eta : t
val theta : t
val vartheta : t
val iota : t
val kappa : t
val varkappa : t
val lambda : t
val mu : t
val nu : t
val xi : t
val pi : t
val varpi : t
val rho : t
val varrho : t
val sigma : t
val varsigma : t
val tau : t
val upsilon : t
val phi : t
val varphi : t
val chi : t
val psi : t
val omega : t
val digamma : t
val gamma_ : t
val delta_ : t
val theta_ : t
val lambda_ : t
val xi_ : t
val pi_ : t
val sigma_ : t
val upsilon_ : t
val phi_ : t
val psi_ : t
val omega_ : t
val aleph : t
val beth : t
val gimel : t
val daleth : t
val le : t
val leq : t
Latex.le
)val leqslant : t
val ge : t
val geq : t
Latex.ge
)val geqslant : t
val equiv : t
val ll : t
val gg : t
val doteq : t
val prec : t
val succ : t
val sim : t
val preceq : t
val succeq : t
val simeq : t
val subset : t
val supset : t
val approx : t
val subseteq : t
val supseteq : t
val cong : t
val sqsubset : t
val sqsupset : t
val join_ : t
val sqsubseteq : t
val sqsupseteq : t
val bowtie : t
val in_ : t
val owns : t
val propto : t
val vdash : t
val dashv : t
val models : t
val mid : t
val parallel : t
val perp : t
val smile : t
val frown : t
val asymp : t
val not_ : t -> t
not_ in_
will print as ∉val notin : t
val ne : t
val neq : t
Latex.ne
)val pm : t
val mp : t
val triangleleft : t
val cdot : t
val div : t
val triangleright : t
val times : t
val setminus : t
val star : t
val cup : t
val cap : t
val ast : t
val sqcup : t
val sqcap : t
val circ : t
val lor_ : t
val land_ : t
val bullet : t
val oplus : t
val ominus : t
val diamond : t
val odot : t
val oslash : t
val uplus : t
val otimes : t
val bigcirc : t
val amalg : t
val bigtriangleup : t
val bigtriangledown : t
val dagger : t
val lhd : t
triangleleft
(latexsym package)val rhd : t
triangleright
(latexsym package)val ddagger : t
dagger
with one more cross on the bottom)val unlhd : t
triangleleft
(latexsym package)val unrhd : t
triangleright
(latexsym package)val wr : t
val sum : t
val prod : t
val coprod : t
val bigcup : t
val bigcap : t
val bigvee : t
val bigwedge : t
val bigsqcup : t
val biguplus : t
val int : t
val oint : t
val bigodot : t
val bigoplus : t
val bigotimes : t
val leftarrow : t
val rightarrow : t
val to_ : t
Latex.rightarrow
)val leftrightarrow : t
val leftarrow_ : t
val rightarrow_ : t
val leftrightarrow_ : t
val longleftarrow : t
val longrightarrow : t
val longleftrightarrow : t
val longleftarrow_ : t
val longrightarrow_ : t
val longleftrightarrow_ : t
val iff : t
val mapsto : t
val longmapsto : t
val hookleftarrow : t
val hookrightarrow : t
val leftharpoonup : t
val rightharpoonup : t
val leftharpoondown : t
val rightharpoondown : t
val rightleftharpoons : t
val uparrow : t
val downarrow : t
val updownarrow : t
val uparrow_ : t
uparrow
val downarrow_ : t
downarrow
val updownarrow_ : t
updownarrow
val nearrow : t
val searrow : t
val swarrow : t
val nwarrow : t
val leadsto : t
val box_ : t
latexsym
.val langle : t
val rangle : t
val lceil : t
val rceil : t
val frac : t -> t -> t
val land_ : t
val lor_ : t
val lnot : t
val neg : t
Latex.lnot
)val forall : t
val exists : t
val top : t
val bot : t
val sharp : t
val dots : t
val cdots : t
...
val ldots : t
val emptyset : t
typedoublable_delimiter =
[ `Down | `Up | `Up_down | `Vert ]
typedelimiter =
[ `Angle
| `Brace
| `Bracket
| `Ceil
| `Double of doublable_delimiter
| `Down
| `Floor
| `None
| `Paren
| `Slash
| `Up
| `Up_down
| `Vert ]
val left : delimiter -> t
val right : delimiter -> t
val just_left : delimiter -> t -> t
just_left d x
: concatenation of left d
, x
and right `None
.val just_right : delimiter -> t -> t
just_right d x
: concatenation of left `None
, x
and right d
.val between : delimiter -> t -> t
between d x
: concatenation of left d
, x
and right d
.val oe : t
val mathbb : t -> t
val mathfrak : t -> t
val align : t -> t
val align_ : t -> t
align
, but without numberingval gather : t -> t
val gather_ : t -> t
val split : t -> t
val proof : ?opt:t -> t -> t
val twoheadrightarrow : t
val square : t
val par_ : t
val black_triangle_left : t
val black_triangle_right : t
val mathpar : t list -> t
and
commands between each item to split them.val inferrule : ?lab:t ->
?left:t ->
?right:t ->
?vdots:size ->
?width:size ->
?leftskip:size ->
?rightskip:size -> t list -> t list -> t
inferrule pre post
builds an inference rule with pre
at the top and post
at the bottom. If pre
or post
is empty, the bar is not drawn.lab
: label to put above the ruleleft
: label to put on the left of the ruleright
: label to put on the right of the rulevdots
: raise the rule and draw vertical dots ; the length argument
is translated to a number of line-skips"stmaryrd"
is automatically added by these commands.val llbracket : t
[|
val rrbracket : t
|]
val llparenthesis : t
(|
val rrparenthesis : t
|)
val slide : t -> t
module type BEAMER =sig
..end
module Beamer:BEAMER
module Verbatim:sig
..end
type
mode =
| |
M |
| |
T |
| |
A |
val empty : t
Equivalent to concat []
or text ""
.
val is_empty : t -> bool
A concatenation of empty trees is also empty.
A tree containing a Latex.set
node is not empty.
A tree containing Latex.get
or Latex.final
nodes is
not empty, even if the call will produce an empty tree when
evaluating variables.
val text : string -> t
val concat : t list -> t
val (^^) : t -> t -> t
val command : ?packages:(string * string) list ->
string ->
?opt:mode * t ->
(mode * t) list -> mode -> t
command name args mode
produces the LaTeX command name
applied to
arguments args
.
The command should be used in mode mode
. For exemple,
the ensuremath
LaTeX command should be used in math mode. The command will
be coerced using mbox
or $ ... $
if mode
differs from the mode it is
used in.
The opt
optional parameter may be used to provide an optional parameter
(in brackets []
) to the LaTeX command.
Arguments opt
and args
must be given with their expected mode and will
be coerced if needed. For example, the mbox
command expect an argument in
text mode (the argument must be coerced using $ ... $
if it is math).
The ensuremath
command expects an argument in any mode.
All packages (name, opt)
given using packages
will automatically be used by
document
.
type
arg_kind
val bracket : arg_kind
val brace : arg_kind
val nobr : arg_kind
val unusual_command : ?packages:(string * string) list ->
string ->
(mode * arg_kind * t) list -> mode -> t
unusual_command
does the same as command
, but is more low level.
Instead of having a single optional argument and a list of mandatory
arguments, it only has a list of arguments.
Each argument comes not only with its content and mode, but with an
"argument kind" (type arg_kind
) specifying whether it is a brace
argument (corresponding to mandatory arguments in command
) or a bracket
argument (corresponding, in turn, to the option argument of command
).
This allows to handle commands which have several optional arguments,
or where optional and mandatory arguments are interleaved.
val within_braces : t -> t
within_braces x
produces {x}
.
Typically meant to be used together with unusual_command
.val environment : ?packages:(string * string) list ->
string ->
?opt:mode * t ->
?args:(mode * t) list ->
mode * t -> mode -> t
Same as function command
, except that it only takes one argument
(the environment body) and produces an environment, i.e. using the
begin
and end
commands. The args
parameters may be used to give
additional arguments, such as the columns of an array.
All packages (name, opt)
given using packages
will automatically be used by
document
.
val mode : mode -> t -> t
mode m x
returns x
if its mode is already m
. If its mode is not m
,
the result is x
coerced using mbox
or $ ... $
.
document
functionsval documentclass : ?opt:mode * t -> t -> t
documentclass cls
means that cls
(represented as a Latex.t
) is the class of the document. The optional
argument is given as a Latex.t
as well, for generality.val required_packages : t
required_packages
. Note that
it does not make sense out of the document's prelude.val require_packages : (t * t) list -> t
require_packages
takes as argument a list of pairs
package,option
. Each package
is required (see packages
) with
option option
. The argument ~packages
of Latex.document
is implemented
as a require_package
. This command can be used anywhere in a document,
if needed.val documentmatter : t -> t
documentmatter body
renders your actual document, body
,
according to the rules specified in the prelude. It is simply
LaTeX's document
command.val latex : t
val usepackage : ?opt:t -> t -> t
~prelude
of your document
, but it is better
to use the ~packages
argument of document
. Note that some commandes
add their own packages to the document automatically.val input : t -> t
.tex
file with macros that you want
to reuse.val newcommand : int -> t -> t -> t
newcommand parameter_count name body
defines a new command with
parameter_count
arguments, where you can use the i
th argument by writing
#i
in the body, just as in Latex. Normally you'd prefer to just define
an OCaml value with let
.val renewcommand : int -> t -> t -> t
newcommand
except that it can redefine existing LaTeX commands.val block : t -> t
block x
produces {x}
. Should only be used in some rare cases when
you want to be very precise about what LaTeX should do.
If x
is empty, the braces are not added. If you need braces even if
x
is empty, use Latex.within_braces
.val place_label : label -> t
place_label lbl
places label lbl
. Normally you would prefer using
the various ~label
optional arguments available, and only use place_label
for unimplemented features or if you are feeling hackish.val atbegindocument : t -> t
val addcontentsline : t -> t -> t -> t
addcontentsline toc section name
val pagestyle : t -> t
val thispagestyle : t -> t
val list_insert : 'a -> 'a list -> 'a list
Examples:
list_insert 1 [] = []
list_insert 1 [2] = [2]
list_insert 1 [2; 3; 4] = [2; 1; 3; 1; 4]
type
env
val get_in_env : ?position:position -> 'a variable -> env -> 'a
val to_buffer : ?mode:mode -> ?env:env -> Buffer.t -> t -> env
val to_channel : ?mode:mode ->
?env:env -> Pervasives.out_channel -> t -> env
val to_file : ?mode:mode -> ?env:env -> string -> t -> env
val to_string : ?mode:mode -> t -> string
val to_string_with_env : ?mode:mode -> ?env:env -> t -> string * env