Tweak the default latex settings.
authorGlenn Hutchings <zondo42@gmail.com>
Mon, 11 Apr 2016 18:32:39 +0000 (19:32 +0100)
committerGlenn Hutchings <zondo42@gmail.com>
Mon, 11 Apr 2016 18:32:39 +0000 (19:32 +0100)
- Add title page
- Add appropriate section numbering
- Add page numbers

conf.py
config/preamble.tex [new file with mode: 0644]
images/harry1.png [new file with mode: 0644]
index.rst

diff --git a/conf.py b/conf.py
index 3201bce7f7125e9d535dcf7ccd8c79492111a5a2..d85a8c6214493b05b801a47e7f75c2a63516a5f1 100644 (file)
--- a/conf.py
+++ b/conf.py
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
-import sys
 import os
 import os
-import shlex
+import sys
+import string
+import codecs
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
@@ -51,14 +52,20 @@ source_suffix = ['.rst']
 # The master toctree document.
 master_doc = 'index'
 
 # The master toctree document.
 master_doc = 'index'
 
-# General information about the project.
-project = u'Inform Beginner\'s Guide'
-author = u'Roger Firth and Sonja Kesserich'
-copyright = u'2016, ' + author
+# General document information.
+project = u"The Inform Beginner's Guide"
+author = u"Roger Firth and Sonja Kesserich"
+copyright = u'2004, ' + author
+
+editor = "Dennis G. Jerz"
+edition = "Third Edition: August 2004"
+extra = "With a foreword by Graham Nelson"
 
 
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
+licensetext = codecs.open('LICENSE', encoding='utf-8').read()
+
+# The version info for the project you're documenting, acts as replacement
+# for |version| and |release|, also used in various other places throughout
+# the built documents.
 #
 # The short X.Y version.
 version = '3'
 #
 # The short X.Y version.
 version = '3'
@@ -80,7 +87,7 @@ language = None
 
 # List of patterns, relative to source directory, that match files and
 # directories to ignore when looking for source files.
 
 # List of patterns, relative to source directory, that match files and
 # directories to ignore when looking for source files.
-exclude_patterns = ['output']
+exclude_patterns = ['config', 'output']
 
 # The reST default role (used for this markup: `text`) to use for all
 # documents.
 
 # The reST default role (used for this markup: `text`) to use for all
 # documents.
@@ -218,25 +225,54 @@ htmlhelp_basename = 'IBG'
 
 # -- Options for LaTeX output ---------------------------------------------
 
 
 # -- Options for LaTeX output ---------------------------------------------
 
+# Title page information.
+latex_image = "harry1"
+latex_image_title = "First Steps"
+latex_image_info = "(watercolour and crayon on paper, 2002) Harry Firth (2000-)"
+latex_image_path = os.path.join('images', latex_image + '.png')
+latex_additional_files = [latex_image_path]
+
+template = string.Template(open('config/preamble.tex').read())
+
+latex_contents = r"""
+\coverpage
+\licensepage
+\contentspage
+\newpage
+\maintext
+"""
+
 latex_elements = {
     # The paper size ('letterpaper' or 'a4paper').
     'papersize': 'a4paper',
 
     # The font size ('10pt', '11pt' or '12pt').
 latex_elements = {
     # The paper size ('letterpaper' or 'a4paper').
     'papersize': 'a4paper',
 
     # The font size ('10pt', '11pt' or '12pt').
-    'pointsize': '10pt',
+    'pointsize': '12pt',
 
     # Additional stuff for the LaTeX preamble.
 
     # Additional stuff for the LaTeX preamble.
-    #'preamble': '',
+    'preamble': template.substitute(title=project,
+                                    author=author,
+                                    image=latex_image,
+                                    imagetitle=latex_image_title,
+                                    imageinfo=latex_image_info,
+                                    editor=editor,
+                                    edition=edition,
+                                    extra=extra,
+                                    licensetext=licensetext),
+
+    'tableofcontents': latex_contents,
+
+    'fontpkg': '',
 
     # Latex figure (float) alignment
     #'figure_align': 'htbp',
 }
 
     # Latex figure (float) alignment
     #'figure_align': 'htbp',
 }
-
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title,
 #  author, documentclass [howto, manual, or own class]).
 latex_documents = [
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title,
 #  author, documentclass [howto, manual, or own class]).
 latex_documents = [
-    (master_doc, 'IBG.tex', project, author, 'manual'),
+    (master_doc, 'IBG.tex', project, author, 'howto'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
@@ -248,7 +284,7 @@ latex_documents = [
 #latex_use_parts = False
 
 # If true, show page references after internal links.
 #latex_use_parts = False
 
 # If true, show page references after internal links.
-#latex_show_pagerefs = False
+latex_show_pagerefs = False
 
 # If true, show URL addresses after external links.
 #latex_show_urls = False
 
 # If true, show URL addresses after external links.
 #latex_show_urls = False
@@ -265,8 +301,7 @@ latex_documents = [
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
-    (master_doc, 'informbeginnersguide', u'Inform Beginner\'s Guide',
-     [author], 1)
+    (master_doc, 'IBG', project, [author], 1)
 ]
 
 # If true, show URL addresses after external links.
 ]
 
 # If true, show URL addresses after external links.
@@ -279,8 +314,8 @@ man_pages = [
 # (source start file, target name, title, author,
 #  dir menu entry, description, category)
 texinfo_documents = [
 # (source start file, target name, title, author,
 #  dir menu entry, description, category)
 texinfo_documents = [
-  (master_doc, 'ibg', u'Inform Beginner\'s Guide',
-   author, 'Inform Beginners Guide', 'Beginner\'s guide to Inform.',
+  (master_doc, 'ibg', project,
+   author, project, 'Beginner\'s guide to Inform.',
    'Games'),
 ]
 
    'Games'),
 ]
 
diff --git a/config/preamble.tex b/config/preamble.tex
new file mode 100644 (file)
index 0000000..8c4f588
--- /dev/null
@@ -0,0 +1,123 @@
+%% LaTeX preamble.
+
+\usepackage[left=2.5cm,right=2.5cm,top=3cm,bottom=3cm]{geometry}
+\usepackage{setspace}
+
+%% Set up page.
+\pagestyle{fancy}
+\pagenumbering{roman}
+\thispagestyle{fancy}
+
+\renewcommand\thepage{\roman{page}}
+\newcommand\pagefoot{\thepage}
+
+%% Set various lengths.
+\setlength{\parskip}{\medskipamount}
+\setlength{\parindent}{0pt}
+
+%% Set section numbering depth.
+\setcounter{secnumdepth}{0}
+
+%% Set up headers and footers.
+\fancyhead{}
+\fancyfoot{}
+
+\renewcommand{\headrulewidth}{0.0pt}
+\renewcommand{\footrulewidth}{0.0pt}
+
+%% Revert to original table of contents.
+\makeatletter
+\renewcommand{\tableofcontents}{\py@OldTableofcontents}
+\makeatother
+
+%% Covering page.
+\def\coverpage{
+    \begin{titlepage}
+    \centering
+    \textbf{\Huge ${title}}\par
+    \vspace{0.5cm}
+    \textbf{\LARGE ${author}}\par
+    \vspace{2cm}
+    \includegraphics[width=\textwidth]{${image}}\par
+    \vspace{2cm}
+    \textit{\large ${edition}}\par
+    \vspace{0.5cm}
+    \textbf{\large ${extra}}\par
+    \vfill
+    \end{titlepage}
+    \newpage
+}
+
+%% License page
+\def\licensepage{
+    \fancyfoot[C]{\pagefoot}
+    ${title}
+
+    Authors: ${author}\par
+    Editor: ${editor}\par
+
+    Cover: \textit{${imagetitle}} ${imageinfo}
+
+    ${licensetext}
+    \newpage
+}
+
+%% Contents page.
+\def\contentspage{
+    \fancyfoot[C]{\pagefoot}
+    \tableofcontents
+}
+
+%% Main text.
+\def\maintext{
+    \fancyfoot[C]{\pagefoot}
+    \pagenumbering{arabic}
+    \renewcommand\thepage{\arabic{page}}
+    \setcounter{page}{1}
+}
+
+%% Start the main chapter text.
+\def\startchapters{
+    \setcounter{secnumdepth}{1}
+}
+
+%% Start the appendices
+\def\startappendices{
+    \setcounter{secnumdepth}{0}
+}
+
+%% Disable standard title (but keep PDF info).
+\renewcommand{\maketitle}{
+  \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{
+      /Title (${title})
+      /Author (${author})
+    }
+    \endgroup
+  \fi
+}
+
+%% Fix up index and references.
+\makeatletter
+
+\renewcommand{\theindex}{
+  \newpage
+  \phantomsection
+  \py@OldTheindex
+  \addcontentsline{toc}{section}{Index}
+}
+
+\renewcommand{\thebibliography}[1]{
+  \newpage
+  \phantomsection
+  \py@OldThebibliography{1}
+  \addcontentsline{toc}{section}{References}
+}
+
+\makeatother
diff --git a/images/harry1.png b/images/harry1.png
new file mode 100644 (file)
index 0000000..7ae0335
Binary files /dev/null and b/images/harry1.png differ
index a9d678ed80d170d6a344608042c10c4d9d27c77e..4dd8608dc4a04552798aaf3c55b9dfb372e476a3 100644 (file)
--- a/index.rst
+++ b/index.rst
@@ -2,16 +2,26 @@
  The Inform Beginner's Guide
 =============================
 
  The Inform Beginner's Guide
 =============================
 
-Contents:
+.. only:: html
+
+   Contents:
+
+   .. toctree::
+      :maxdepth: 2
+
+      copyright
+      history
 
 .. toctree::
    :maxdepth: 2
 
 
 .. toctree::
    :maxdepth: 2
 
-   copyright
-   history
    foreword
    about
 
    foreword
    about
 
+.. raw:: latex
+
+   \startchapters
+
 .. toctree::
    :maxdepth: 2
    :glob:
 .. toctree::
    :maxdepth: 2
    :glob:
@@ -19,21 +29,31 @@ Contents:
 
    chapters/*
 
 
    chapters/*
 
-Appendices:
+.. only:: html
+
+   Appendices:
+
+.. raw:: latex
+
+   \startappendices
 
 .. toctree::
    :glob:
 
    appendices/*
 
 
 .. toctree::
    :glob:
 
    appendices/*
 
-Indices:
+.. only:: html
+
+   Indices:
 
 * :ref:`genindex`
 * :ref:`search`
 
 
 * :ref:`genindex`
 * :ref:`search`
 
-End notes:
+.. only:: html
 
 
-.. toctree::
-   :maxdepth: 2
+   End notes:
+
+   .. toctree::
+      :maxdepth: 2
 
 
-   endnotes
+      endnotes