HaTeX-3.17.0.2: The Haskell LaTeX library.

Safe HaskellNone
LanguageHaskell2010

Text.LaTeX.Base.Commands

Contents

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 

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 #

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.

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

Start a new subsection.

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

Start a new 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.

lnbk :: LaTeXC l => l Source #

Start a new line. In a tabular, it starts a new row, so use newline instead.

lnbk_ :: LaTeXC l => l Source #

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

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

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

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

hfill :: LaTeXC l => l Source #

Fill out all available horizontal space.

vfill :: LaTeXC l => l Source #

Fill out all available vertical space.

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

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

-> l 

Figure environment.

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.

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 #

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.

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.