|
| 1 | +\RequirePackage{luatex85} |
| 2 | +\documentclass[a4paper]{book} |
| 3 | + |
| 4 | +\newdimen\sphinxpxdimen |
| 5 | +\sphinxpxdimen=.75bp |
| 6 | +\ifdefined\pdfimageresolution \pdfimageresolution= 96\relax\fi |
| 7 | + |
| 8 | +\catcode`^^^^00a0\active\protected\def^^^^00a0{\leavevmode\nobreak\ } |
| 9 | + |
| 10 | +\usepackage{fontspec} |
| 11 | +\usepackage{mathpazo} |
| 12 | +\linespread{1.05} % see http://www.tug.dk/FontCatalogue/urwpalladio/ |
| 13 | +\setmainfont{TeX Gyre Pagella}[Numbers=OldStyle] |
| 14 | +\setmonofont{Latin Modern Mono Light}[Numbers=Lining] |
| 15 | + |
| 16 | +\usepackage{amsmath,amssymb,amstext} |
| 17 | + |
| 18 | +\usepackage{polyglossia} |
| 19 | +\setmainlanguage{english} |
| 20 | + |
| 21 | +\usepackage[booktabs]{sphinx} |
| 22 | +\sphinxsetup{ |
| 23 | +%verbatimwrapslines=false, |
| 24 | +%verbatimhintsturnover=false, |
| 25 | +div.note_border-TeXcolor={HTML}{E0E0E0}, |
| 26 | +div.note_border-width=0.5pt, |
| 27 | +div.warning_border-TeXcolor={HTML}{E0E0E0}, |
| 28 | +div.warning_border-width=1.5pt, |
| 29 | +div.warning_background-TeXcolor={HTML}{FBFBFB}, |
| 30 | +} |
| 31 | +\fvset{fontsize=\small} |
| 32 | + |
| 33 | +\usepackage{nbsphinx} |
| 34 | + |
| 35 | +\usepackage[ |
| 36 | +style=authoryear-comp, |
| 37 | +backref=true, |
| 38 | +]{biblatex} |
| 39 | +% We need the original bibliography from the Sphinx project ... |
| 40 | +\addbibresource{../doc/references.bib} |
| 41 | +% ... and we can add our own if we want: |
| 42 | +\addbibresource{my-own-references.bib} |
| 43 | + |
| 44 | +% This should be the last package in the preamble: |
| 45 | +\usepackage{hyperref} |
| 46 | + |
| 47 | +\sphinxsetup{ |
| 48 | +InnerLinkColor={named}{black}, |
| 49 | +OuterLinkColor={named}{black}, |
| 50 | +} |
| 51 | + |
| 52 | +\title{Including Sphinx-Generated Content in a \LaTeX\ Document} |
| 53 | + |
| 54 | +\begin{document} |
| 55 | + |
| 56 | +\maketitle |
| 57 | + |
| 58 | +\tableofcontents |
| 59 | + |
| 60 | +\chapter{A Hand-Written \LaTeX\ Chapter} |
| 61 | + |
| 62 | +\section{References to Sphinx Content} |
| 63 | + |
| 64 | +We can create references to the Sphinx content, |
| 65 | +for example to section~\ref{code-cells:Code,-Output,-Streams}. |
| 66 | + |
| 67 | + |
| 68 | +\section{Bibliography} |
| 69 | + |
| 70 | +We can cite bibliography items from the Sphinx project: |
| 71 | +\parencite{perez2011python}. |
| 72 | +But we can also use our own bibliography file: |
| 73 | +\parencite{knuth1986texbook}. |
| 74 | + |
| 75 | +We only have to make sure that the bibliography keys are unique. |
| 76 | + |
| 77 | +\section{Code Blocks} |
| 78 | + |
| 79 | +We can use the \texttt{sphinxVerbatim} environment |
| 80 | +to get code blocks like those generated by Sphinx: |
| 81 | + |
| 82 | +\begin{sphinxVerbatim} |
| 83 | +some code |
| 84 | +\end{sphinxVerbatim} |
| 85 | + |
| 86 | +\begin{sphinxVerbatim}[commandchars=\\\{\}] |
| 87 | +some code with \emph{markup} |
| 88 | +\end{sphinxVerbatim} |
| 89 | + |
| 90 | +With a little additional work |
| 91 | +we can even use the same syntax highlighting as Sphinx uses: |
| 92 | + |
| 93 | +See \texttt{pygmentize.py}: |
| 94 | + |
| 95 | +\input{pygmentize.py} |
| 96 | + |
| 97 | +\dots and \texttt{latexmkrc}: |
| 98 | + |
| 99 | +\input{latexmkrc} |
| 100 | + |
| 101 | +\chapter{A Chapter Containing a Sphinx Project} |
| 102 | + |
| 103 | +Depending on whether the last element of \texttt{latex\_documents} |
| 104 | +(\url{https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-latex_documents}) |
| 105 | +is \texttt{False} or \texttt{True}, |
| 106 | +the content of the main source file (without the main heading) |
| 107 | +is shown here or not, respectively: |
| 108 | + |
| 109 | +% NB: The name of the input file is defined with latex_documents in conf.py: |
| 110 | +\input{_build/nbsphinx-chapter} |
| 111 | + |
| 112 | +\printbibliography[title=References,heading=bibintoc] |
| 113 | + |
| 114 | +\end{document} |
0 commit comments