logo

Easylatex Filter

← Back to Filter List

Easylatex


Wraps your text in LaTeX article header/footer. Easy way to generate a document which can be compiled using LaTeX (includes Pygments syntax highlighting).

Aliases for this filter

  • easylatex

Converts from file formats:

  • .tex

To file formats:

  • .tex

Available settings:

SettingDescriptionDefault
add-new-filesBoolean or list of extensions/patterns to match.False
added-in-versionDexy version when this filter was first available.
additional-doc-filtersFilters to apply to additional documents created as side effects.{}
additional-doc-settingsSettings to apply to additional documents created as side effects.{}
authorAuthor of article.
data-typeAlias of custom data class to use to store filter output.generic
dateDate of article.
documentclassThe document class to generate.article
examplesTemplates which should be used as examples for this filter.[]
exclude-add-new-filesList of patterns to skip even if they match add-new-files.[]
exclude-new-files-from-dirList of directories to skip when adding new files.[]
extFile extension to output.None
extension-mapDictionary mapping input extensions to default output extensions.None
fontThe font size to use.11pt
helpHelpstring for plugin.Wraps your text in LaTeX article header/footer. Easy way to generate a document which can be compiled using LaTeX (includes Pygments syntax highlighting).
input-extensionsList of extensions which this filter can accept as input.[u'.tex']
keep-originalsWhether, if additional-doc-filters are specified, the original unmodified docs should also be added.False
mkdirA directory which should be created in working dir.None
mkdirsA list of directories which should be created in working dir.[]
nodocWhether filter should be excluded from documentation.False
outputWhether to output results of this filter by default by reporters such as 'output' or 'website'.False
output-extensionsList of extensions which this filter can produce as output.[u'.tex']
override-workspace-exclude-filtersIf True, document will be populated to other workspaces ignoring workspace-exclude-filters.False
papersizeThe document class to generate.a4paper
preambleAdditional custom LaTeX content to include in header.
preserve-prior-data-classWhether output data class should be set to match the input data class.False
require-outputShould dexy raise an exception if no output is produced by this filter?True
styleThe pygments style to use.default
tagsTags which describe the filter.[]
titleTitle of article.
variablesA dictionary of variable names and values to make available to this filter.{}
varsA dictionary of variable names and values to make available to this filter.{}
workspace-exclude-filtersFilters whose output should be excluded from workspace.[u'pyg']
workspace-includesIf set to a list of filenames or extensions, only these will be populated to working dir.None
Filter Source Code
class EasyLatex(DexyFilter):
    """
    Wraps your text in LaTeX article header/footer.
    Easy way to generate a document which can be compiled using LaTeX (includes
    Pygments syntax highlighting).
    """
    aliases = ['easylatex']
    _settings = {
            'input-extensions' : ['.tex'],
            'output-extensions' : ['.tex'],
            'documentclass' : ("The document class to generate.", "article"),
            'style' : ("The pygments style to use.", "default"),
            'title' : ("Title of article.", ""),
            'author' : ("Author of article.", ""),
            'date' : ("Date of article.", ""),
            'font' : ("The font size to use.", "11pt"),
            'papersize' : ("The document class to generate.", "a4paper"),
            "preamble" : ("Additional custom LaTeX content to include in header.", "")
            }

    def pygments_sty(self):
        formatter = LatexFormatter(style=self.setting('style'))
        return formatter.get_style_defs()

    def process_text(self, input_text):
        args = self.setting_values()
        args['input'] = input_text
        args['pygments'] = self.pygments_sty()

        if self.setting('title'):
            args['title'] = r"\title{%(title)s}" % args
            args['maketitle'] = r"\maketitle"
        else:
            args['title'] = ""
            args['maketitle'] = ""

        if self.setting('date'):
            args['date'] = r"\date{%(date)s}" % args

        if self.setting('author'):
            args['author'] = r"\author{%(author)s}" % args

        return self.template % args

    template = r"""\documentclass[%(font)s,%(papersize)s]{%(documentclass)s}
\usepackage{color}
\usepackage{fancyvrb}
%(pygments)s

%(preamble)s

%(title)s
%(author)s
%(date)s

\begin{document}

%(maketitle)s


%(input)s

\end{document}
"""

Content © 2013 Dr. Ana Nelson | Site Design © Copyright 2011 Andre Gagnon | All Rights Reserved.