# File lib/maruku/output/to_latex.rb, line 45
  def to_latex_document
    body = to_latex

    if get_setting(:maruku_signature)
      body << render_latex_signature
    end

    required = self.latex_required_packages.map do |p|
      "\\usepackage{#{p}}\n"
    end.join

    #=begin maruku_doc
    # Attribute: latex_cjk
    # Scope:     document
    # Output:    latex
    # Summary:   Support for CJK characters.
    #
    # If the `latex_cjk` attribute is specified, then appropriate headers
    # are added to the LaTeX preamble to support Japanese fonts.
    # You have to have these fonts installed -- and this can be a pain.
    #
    # If `latex_cjk` is specified, this is added to the preamble:
    #
    # <?mrk puts "ciao" ?>
    #
    # <?mrk md_codeblock(Maruku::MDDocument::Latex_preamble_enc_cjk) ?>
    #
    #
    # while the default is to add this:
    #
    # <?mrk md_codeblock(Maruku::MDDocument::Latex_preamble_enc_utf8) ?>
    #
    #=end

    encoding = get_setting(:latex_cjk) ? Latex_preamble_enc_cjk : Latex_preamble_enc_utf8

    #=begin maruku_doc
    # Attribute: latex_preamble
    # Scope:     document
    # Output:    latex
    # Summary:   User-defined preamble.
    #
    # If the `latex_preamble` attribute is specified, then its value
    # will be used as a custom preamble.
    #
    # For example:
    #
    #   Title: My document
    #   Latex preamble: preamble.tex
    #
    # will produce:
    #
    #   ...
    #   \input{preamble.tex}
    #   ...
    #
    #=end

    user_preamble = (file = @doc.attributes[:latex_preamble]) ? "\\input{#{file}}\n" : ""

    "\\documentclass{article}

% Packages required to support encoding
#{encoding}

% Packages required by code
#{required}

% Packages always used
\\usepackage{hyperref}
\\usepackage{xspace}
\\usepackage[usenames,dvipsnames]{color}
\\hypersetup{colorlinks=true,urlcolor=blue}

#{user_preamble}

\\begin{document}
#{body}
\\end{document}
"
  end