HaTeX-3.22.3.2: The Haskell LaTeX library.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.LaTeX.Base.Commands

Description

This module is the Prelude of LaTeX functions. It includes commands, environments, and some other useful abstractions, that don't require you to import additional LaTeX packages.

Synopsis

Basic functions

raw :: LaTeXC l => Text -> l Source #

Insert a raw piece of Text. This functions doesn't escape LaTeX reserved characters, it insert the text just as it is received.

Warning: This function is unsafe, in the sense that it does not check that the input text is a valid LaTeX block. Make sure any braces, commands or environments are properly closed.

between :: Monoid m => m -> m -> m -> m Source #

Calling between c l1 l2 puts c between l1 and l2 and appends them.

between c l1 l2 = l1 <> c <> l2

comment :: LaTeXC l => Text -> l Source #

Create a comment.

(%:) :: LaTeXC l => l -> Text -> l Source #

This operator appends a comment after a expression. For example:

textbf "I'm just an example." %: "Insert a few words here."

The implementation is

(%:) l = (l <>) . comment

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. It may be useful for debugging the output as well.

Preamble commands

title :: LaTeXC l => l -> l Source #

Set the title of your document.

author :: LaTeXC l => l -> l Source #

Set the author(s) of the document.

date :: LaTeXC l => l -> l Source #

Set a date for your document.

institute :: LaTeXC l => Maybe l -> l -> l Source #

Set either an institute or an organization for the document. It does not work for a document of the article class.

thanks :: LaTeXC l => l -> l Source #

documentclass Source #

Arguments

:: LaTeXC l 
=> [ClassOption]

Class options

-> ClassName

Class name

-> l 

Set the document class. Needed in all documents.

usepackage :: LaTeXC l => [l] -> PackageName -> l Source #

Import a package. First argument is a list of options for the package named in the second argument.

Classes

Document classes

Class options

landscape :: ClassOption Source #

Changes the layout of the document to print in landscape mode

openright :: ClassOption Source #

Makes chapters begin either only on right hand pages

openany :: ClassOption Source #

Makes chapters begin on the next page available.

fleqn :: ClassOption Source #

Typesets displayed formulae left-aligned instead of centred.

leqno :: ClassOption Source #

Places the numbering of formulae on the left hand side instead of the right.

Paper sizes

data PaperType Source #

LaTeX available paper types.

Constructors

A0 
A1 
A2 
A3 
A4 
A5 
A6 
B0 
B1 
B2 
B3 
B4 
B5 
B6 
Letter 
Executive 
Legal 

Instances

Instances details
Render PaperType Source # 
Instance details

Defined in Text.LaTeX.Base.Commands

Show PaperType Source # 
Instance details

Defined in Text.LaTeX.Base.Commands

Page styles

markboth :: LaTeXC l => l -> l -> l Source #

Used in conjunction with myheadings for setting both the left and the right heading.

markright :: LaTeXC l => l -> l Source #

Used in conjunction with myheadings for setting the right heading.

Body commands

document :: LaTeXC l => l -> l Source #

The document environment contains the body of the document.

maketitle :: LaTeXC l => l Source #

Append a blank comment. eol :: LaTeXC l => l eol = comment ""

Generate the title. It normally contains the title name of your document, the author(s) and date.

Document structure

tableofcontents :: LaTeXC l => l Source #

Create the table of contents, automatically generated from your sections, subsections, and related functions.

abstract :: LaTeXC l => l -> l Source #

Abstract section.

Sections

part :: LaTeXC l => l -> l Source #

chapter :: LaTeXC l => l -> l Source #

Start a new chapter with the given title.

section :: LaTeXC l => l -> l Source #

Start a new section with a given title.

section' :: LaTeXC l => l -> l Source #

Start a new unnumbered section with a given title.

subsection :: LaTeXC l => l -> l Source #

Start a new subsection.

subsection' :: LaTeXC l => l -> l Source #

Start a new unnumbered subsection.

subsubsection :: LaTeXC l => l -> l Source #

Start a new subsubsection.

subsubsection' :: LaTeXC l => l -> l Source #

Start a new unnumbered subsubsection.

paragraph :: LaTeXC l => l -> l Source #

Start a paragraph.

subparagraph :: LaTeXC l => l -> l Source #

Start a subparagraph (minimal level of sectioning).

Logos & symbols

today :: LaTeXC l => l Source #

Render the date at compilation time.

thePage :: LaTeXC l => l Source #

Render the current page.

tex :: LaTeXC l => l Source #

TeX logo.

latex :: LaTeXC l => l Source #

The LaTeX logo.

laTeX2 :: LaTeXC l => l Source #

LaTeX logo.

laTeXe :: LaTeXC l => l Source #

ldots :: LaTeXC l => l Source #

Horizontal dots.

vdots :: LaTeXC l => l Source #

Vertical dots.

ddots :: LaTeXC l => l Source #

Diagonal dots.

HaTeX specific

hatex :: LaTeXC l => l Source #

Print the HaTeX logo.

hatex3 :: LaTeXC l => l Source #

Print the HaTeX 3 logo.

hatex_version :: LaTeXC l => l Source #

Print the HaTeX logo, beside the complete version number.

Document layout

par :: LaTeXC l => l Source #

Start a new paragraph

newline :: LaTeXC l => l Source #

Start a new line. It can be used only in paragraph mode.

lnbk :: LaTeXC l => l Source #

Start a new line. The exactly meaning depends on the context where it is used. In normal running text when it forces a line break it is essentially a shorthand for '\newline' (does not end horizontal mode or end the paragraph, it just inserts some glue and penalties at that point into the horizontal material so that when the paragraph does end a line break will occur at that point with the short line padded with white space). In alignment environments (like tabular), it starts a new row, so use newline instead to start a new line.

lnbk_ :: LaTeXC l => l Source #

Like lnbk, lnbk_ introduces a line break, but preventing a page break.

lnbkspc :: LaTeXC l => Measure -> l Source #

Like lnbk, introduces a line break. But it has an argument that specifies how much extra vertical space is to be inserted before the next line. This can be a negative amount.

lnbkspc_ :: LaTeXC l => Measure -> l Source #

Like lnbkspc, lnbkspc_ introduces a line break with an extra vertical space, but preventing a page break.

linebreak :: LaTeXC l => l -> l Source #

Request to break the current line at the point of the command stretching the line so that it extends to the right margin. The number must be a number from 0 to 4. The higher the number, the more insistent the request is (0 means it will be easily ignored and 4 means do it anyway). When this line break option is used, LaTeX will try to produce the best line breaks possible.

nolinebreak :: LaTeXC l => l -> l Source #

Like linebreak, but prevents a like break instead of requesting one.

pagebreak :: LaTeXC l => Maybe l -> l Source #

vspace :: LaTeXC l => Measure -> l Source #

Add vertical white space, except at the end of a page.

vspace_ :: LaTeXC l => Measure -> l Source #

Add vertical white space, even at the end of a page.

addvspace :: LaTeXC l => Measure -> l Source #

Add extra vertical white space. In a sequence of addvspace the length of the final white space is given by the maximum of the individual lengths.

quad :: LaTeXC l => l Source #

Space equal to the current font size (= 18 mu). \(a\quad b\)

qquad :: LaTeXC l => l Source #

Twice of quad (= 36 mu). \(a\qquad b\)

hfill :: LaTeXC l => l Source #

Fill out all available horizontal space.

vfill :: LaTeXC l => l Source #

Fill out all available vertical space.

dotfill :: LaTeXC l => l Source #

Fill out all available horizontal space with dots.

hrulefill :: LaTeXC l => l Source #

Fill out all available horizontal space with a line.

indent :: LaTeXC l => l Source #

Document measures

Formatting text

verbatim :: LaTeXC l => Text -> l Source #

The point of verbatim is to include text that will not be parsed as LaTeX in any way at all, but should simply appear as given in the document, in a separate display in typewriter font.

verb :: LaTeXC l => Text -> l Source #

Include text, as given and in typewriter, but in-line. Note that, for LaTeX-specific technical reasons, verbatim text can generally only be used "at the top level", not in e.g. section titles or other command-arguments.

Unlike verbatim, which LaTeX implements as an ordinary environment, its command verb uses a syntax trick to avoid braking its parsing when the literal text contains a closing brace: rather than using braces at all, the first character after \verb will be the right delimiter as well. Translating this method to HaTeX wouldn't really make sense since Haskell has string literals with their own escaping possibilities; instead, we make it secure by automatically choosing a delimiter that does not turn up in the given string.

Fonts

textbf :: LaTeXC l => l -> l Source #

Set the given argument to bold font face.

textit :: LaTeXC l => l -> l Source #

texttt :: LaTeXC l => l -> l Source #

Set the given argument to monospaced font.

textrm :: LaTeXC l => l -> l Source #

textsf :: LaTeXC l => l -> l Source #

textmd :: LaTeXC l => l -> l Source #

textup :: LaTeXC l => l -> l Source #

textsl :: LaTeXC l => l -> l Source #

textsc :: LaTeXC l => l -> l Source #

Set the given argument to small caps format.

textnormal :: LaTeXC l => l -> l Source #

underline :: LaTeXC l => l -> l Source #

emph :: LaTeXC l => l -> l Source #

Sizes

Sizes are sorted from smallest to biggest.

tiny :: LaTeXC l => l -> l Source #

scriptsize :: LaTeXC l => l -> l Source #

footnotesize :: LaTeXC l => l -> l Source #

small :: LaTeXC l => l -> l Source #

normalsize :: LaTeXC l => l -> l Source #

large :: LaTeXC l => l -> l Source #

large2 :: LaTeXC l => l -> l Source #

large3 :: LaTeXC l => l -> l Source #

huge :: LaTeXC l => l -> l Source #

huge2 :: LaTeXC l => l -> l Source #

Environments

Math environments, such as equation, defined in Text.LaTeX.Packages.AMSMath.

enumerate :: LaTeXC l => l -> l Source #

Environment of ordered lists. Use item to start each list item.

itemize :: LaTeXC l => l -> l Source #

Environment of unordered lists. Use item to start each list item.

item :: LaTeXC l => Maybe l -> l Source #

An item of a list (see enumerate or itemize). The optional argument sets the design of the item.

flushleft :: LaTeXC l => l -> l Source #

Left-justify the argument.

flushright :: LaTeXC l => l -> l Source #

Right-justify the argument.

center :: LaTeXC l => l -> l Source #

Center-justify the argument.

quote :: LaTeXC l => l -> l Source #

verse :: LaTeXC l => l -> l Source #

cite :: LaTeXC l => l -> l Source #

description :: LaTeXC l => l -> l Source #

minipage Source #

Arguments

:: LaTeXC l 
=> Maybe Pos

Optional position

-> l

Width

-> l

Minipage content

-> l 

Minipage environment.

figure Source #

Arguments

:: LaTeXC l 
=> Maybe Pos

Optional position.

-> l

Figure content (should usually contain includegraphics, caption and label).

-> l 

Figure environment. Use this for floating Text.LaTeX.Packages.Graphicx content out of the text block and giving it a caption. The figure can be referred to with ref from elsewhere in the document.

table Source #

Arguments

:: LaTeXC l 
=> [Pos]

Position preferences. Leave empty to use default.

-> l

Table content (assemble with tabular/matrixTabular, caption and label).

-> l 

Table environment. Use this for floating a tabular out of the text block and giving it a caption. The table can be referred to with ref.

Page numbering

pagenumbering :: LaTeXC l => l -> l Source #

arabic :: LaTeXC l => l Source #

Arabic numerals.

roman :: LaTeXC l => l Source #

Lowercase roman numerals.

roman_ :: LaTeXC l => l Source #

Uppercase roman numerals.

alph :: LaTeXC l => l Source #

Lowercase letters.

alph_ :: LaTeXC l => l Source #

Uppercase letters.

Boxes

mbox :: LaTeXC l => l -> l Source #

fbox :: LaTeXC l => l -> l Source #

parbox :: LaTeXC l => Maybe Pos -> Measure -> l -> l Source #

framebox :: LaTeXC l => Maybe Measure -> Maybe HPos -> l -> l Source #

makebox :: LaTeXC l => Maybe Measure -> Maybe HPos -> l -> l Source #

rule Source #

Arguments

:: LaTeXC l 
=> Maybe Measure

Optional lifting.

-> Measure

Width.

-> Measure

Height.

-> l 

Produce a simple black box.

Cross references

caption :: LaTeXC l => l -> l Source #

label :: LaTeXC l => l -> l Source #

ref :: LaTeXC l => l -> l Source #

pageref :: LaTeXC l => l -> l Source #

Tables

tabular Source #

Arguments

:: 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.

The tabular environment can be used to typeset tables with optional horizontal and vertical lines.

tabularnewline :: LaTeXC l => l Source #

tabularnewline ends a row in array or tabular environments. The '\' command has different meanings in different contexts. It can end a line in normal text, or it can end an array or tabular line. It may be preferrable to use newline and in the first case, and tabularnewline in the second.

arraybackslash :: LaTeXC l => l Source #

arraybackslash resets the definition of '\' to tabularnewline.

array Source #

Arguments

:: 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.

Like tabular but in math mode by default

(&) :: LaTeXC l => l -> l -> l Source #

Column separator.

hline :: LaTeXC l => l Source #

Horizontal line.

cline :: LaTeXC l => Int -> Int -> l Source #

cline i j writes a partial horizontal line beginning in column i and ending in column j.

multicolumn :: LaTeXC l => Int -> [TableSpec] -> l -> l Source #

Cell taking multiple columns.

Special tables

matrixTabular Source #

Arguments

:: (LaTeXC l, Texy a) 
=> [l]

(Non-empty) List of column titles

-> Matrix a

Matrix of data

-> l

Data organized in a tabular environment

If you are able to arrange some data in matrix form, you might want to use this function to quickly generate a tabular with your data. Each element of the matrix is rendered using the Texy instance of its type. If you want a custom instance for an already instantiated type, wrap that type using newtype, and then create your own instance. Since every element of a matrix must be of the same type, for mixed tables you might want to create an union type. For example, if your data matrix contains Ints and Doubles:

data Number = R Double | I Int

instance Texy Number where
  texy (R x) = texy x
  texy (I x) = texy x

Now you can have a matrix of type Matrix Number and use it to render your mixed data in a LaTeX table.

The function matrixTabular does not give you many options, so it is not as flexible as generating the table by yourself, but it uses a reasonable standard style.

A very simple example:

matrixTabular (fmap textbf ["x","y","z"]) $
  fromList 3 3 [ (1 :: Int)..]

This code generates the following table:

For more examples see the file Examples/tables.hs, included in the source distribution.

For more info about how to generate and manipulate matrices, see Data.Matrix.

Others

footnote :: LaTeXC l => l -> l Source #

footnotemark :: LaTeXC l => l Source #

Prints a foot note mark but without the actual footnote.

footnotetext :: LaTeXC l => l -> l Source #

Prints the footnote corresponding to the previous footnotemark. Useful when dealing with footnotes in tabular environment.

stepcounter :: LaTeXC l => String -> l Source #

Increases by 1 the value of given counter

addtocounter :: LaTeXC l => String -> Int -> l Source #

Increases by n the value of given counter t

protect :: LaTeXC l => l -> l Source #

hyphenation :: LaTeXC l => l -> l Source #

hyp :: LaTeXC l => l Source #

qts :: LaTeXC l => l -> l Source #

Quotation marks.

Maths commands

External files

input :: LaTeXC l => FilePath -> l Source #

Import an external file and insert its content as it is.

include :: LaTeXC l => FilePath -> l Source #

Similar to input, but forces a page break.

Note: the file you are including cannot include other files.