I generate a variety of documents, but they all have the "same" title page format, but the title, document number, etc differ. I store my preamble in a file that is a string.Template and then load it.
PREAMBLE = string.Template(open(
os.path.join(os.path.abspath('.'),'latex_templates/preamble.tex')
).read())latex_contents = r'''
\setupHeadFootForFrontMatter
\formattoc
\maketitle
\signaturepage
\revisionhistory
\tableofcontents
\clearpage
\listoffigures
\clearpage
\listoftables
\clearpage
\setupHeadFootForText
\pagenumbering{arabic}
\pagestyle{plain}
'''latex_elements = {
# ... put your stuff here
# Customize below for your template
'preamble': PREAMBLE.substitute(docrevision=document_rev,
documentnumber=documentnumber,
),
# Redefine tableofcontents to be the commands you want to run
'tableofcontents': latex_contents,
# Make this not look like a book
'classoptions': ',openany,oneside',
# .. Anything else you want to do
}
latex_additional_files = ['latex_templates/my_style.sty',
]\renewcommand{\maketitle}{%
\begin{titlepage}%
\pagenumbering{roman}
\thispagestyle{titlepage}
\let\footnotesize\small
\let\footnoterule\relax
%\rule{\textwidth}{1pt}%
\ifsphinxpdfoutput
\begingroup
% These \defs are required to deal with multi-line authors; it
% changes \\ to ', ' (comma-space), making it pass muster for
% generating document info in the PDF file.
\def\\{, }
\def\and{and }
\pdfinfo{
/Author (\@author)
/Title (\@title)
}
\endgroup
\fi
\begin{center}%
{\rm\Huge\py@HeaderFamily \@title \par}%
{\em\LARGE\py@HeaderFamily \py@release\releaseinfo \par}
\vfill
{\LARGE\py@HeaderFamily
\begin{tabular}[t]{c}
\@author
\end{tabular}
\par}
\py@authoraddress \par
\vfill\vfill
{\large
\vfill
%\@date \par
\vfill
}%
\end{center}%\par
\@thanks
\end{titlepage}%
\cleardoublepage%
\setcounter{footnote}{0}%
\let\thanks\relax\let\maketitle\relax
%\@ifundefined{fancyhf}{}{\pagestyle{normal}}%
}The preamble has sections that look like this to make it work like a template:
\def\documentnumber{${documentnumber}}
\def\docrevision{${docrevision}}
It really is only a slightly modified version, but I broke out the table of contents into latex_contents. Then added table of tables, table of figures, modified the headers/footer, etc there as well.
'preamble': r''' \makeatletter \renewcommand{\maketitle}{ \begin{titlepage} \noindent \Huge \@date \par \end{titlepage} } \makeatother''',
--
You received this message because you are subscribed to a topic in the Google Groups "sphinx-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sphinx-users/S_ip2b-lrRs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sphinx-users+unsubscribe@googlegroups.com.
There should be a slightly less obvious way to do it. I have considered doing it, but it makes the .rst files a bit more difficult to read. Note that I have not tried this, it is only a guess at what you would need to do.latex_elements = {
# ... put your stuff here
# Customize below for your template
'preamble': my_preamble,
# Redefine tableofcontents to be the commands you want to run
'tableofcontents': \make_title_page_only,
# .. Anything else you want to do
}
\tableofcontents
Now, update your index.rst file to have a toctree that isn't numbered:
.. toctree::
copyright
trademark
main_toctree
Now you can put in your copyright, etc
Move the normal toctree into a separate file called main_toctree.rst (or pick a better name). In that one, you probably want it numbered:
.. raw:: latex
\tableofcontents
.. toctree::
:numbered:
:glob:
put_your_previous_toctree_entries_here
Now your .rst files should build your html files and latex files in the same order and you *should* be able to have .rst content before your table of contents. This now makes it a bit more difficult to get your header/footers correct (if you switch between roman/arabic numbers in you footers for example). You maybe able work around this by including more .. raw:: latex directives.
If you go that route and it works, please let me know.--You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users+unsubscribe@googlegroups.com.