summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/hybrid-latex/examples/summary.tex
blob: d05a66dc6403cfaaf9449058b4a48db4c84e49cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
\documentclass[12pt]{article}
\usepackage{pylatex}
\usepackage{geometry}
\usepackage{pgf}
\usepackage{amsmath}
\usepackage{listings}
\usepackage{hyperref}
\usepackage{breqn}
\usepackage{caption}
\usepackage{examples}

\geometry{papersize={210mm,297mm},hmargin=2cm,tmargin=1.0cm,bmargin=1.5cm}

\def\pyLaTeX{{\tt\small pyLaTeX}}

\begin{document}

\section*{Using output from other sources}

This document performs no computations (i.e., it has no active code blocks) but instead uses selected parts of the output created by other documents. Thus this document can be compiled using {\tt\small pdflatex summary}. The basic structure of this document is as follows.

\begin{minipage}[t]{0.75\textwidth}
\begin{latex}
   \documentclass[12pt]{article}
   \usepackage{pylatex}    % so that we can use \py{foo}
   \usepackage{amsmath}
   ...                     % other packages such as geometry, hyperref, breqn etc.
   \begin{document}
      ...
      \input{example-01.pytex}  % all Python output from example-01.tex
      ...
      \begin{align*}
         &\py*{ans.301}\\       % the Python output
         &\py*{ans.302}
      \end{align*}
      ...
      \input{example-02.pytex}  % all Python output from example-02.tex
      ...
      \begin{align*}
         &\py*{ans.401}\\       % the Python output
         &\py*{ans.402}
      \end{align*}
      ...
   \end{document}
\end{latex}
\end{minipage}

\vspace{10pt}

Note that care must be taken to avoid name clashes across tags from different sources. If two or more sources define tags with the same name (e.g., {\tt\small foo.pytex} and {\tt\small bah.pytex} both define {\tt\small\verb|\pytag{ans.101}|}) then the last definition will be used.

\section*{Example 1}

\input{example-01.pytex}

\begin{align*}
   &\py*{ans.102}\\
   &\py*{ans.302}\\
   &\py*{ans.303}\\
   &\py*{ans.305}\\
   &\py*{ans.401}\\
   &\py*{ans.402}\\
   &\py*{ans.403}\\
   &\py*{ans.404}
\end{align*}

\section*{Example 2}

\input{example-02.pytex}

\begin{align*}
   \py {CalculusTable}
\end{align*}

\section*{Example 3}

\input{example-03.pytex}

\begin{align*}
   \py{lhs.01} &= \py{rhs.01}\\
               &= \py{rhs.02}\\
               &= \py{rhs.03}\\
               &= \py{rhs.04}\\
               &\approx \py{rhs.05}
\end{align*}

\clearpage

\section*{Example 4}

\begin{minipage}{\textwidth}
   \centering
   \IfFileExists{example-04-fig.pdf}%
   % {\scalebox{0.75}{\input{example-04-fig.pdf}}}{Failed to create plot.}
   {\includegraphics[width=6.4in]{example-04-fig.pdf}}{Failed to create plot.}
   \captionof{figure}{The first six Bessel functions.}
\end{minipage}

\section*{Example 5}

\input{example-05.pytex}

\begin{dgroup*}[spread={5pt}]
   \begin{dmath*} f(x) = \Py*{ans.511} \end{dmath*}
   \begin{dmath*}    {}= \Py*{ans.512} \end{dmath*}
   \begin{dmath*}    {}= \Py*{ans.513} \end{dmath*}
   \begin{dmath*}    {}= \Py*{ans.514} \end{dmath*}
   \begin{dmath*}    {}= \Py*{ans.514} \end{dmath*}% LCB: do we need extar space for the tag?
\end{dgroup*}

\section*{Example 6}

\input{example-06.pytex}

\def\eps{\epsilon}
\def\RuleA{\vrule depth0pt  width0pt height14pt}
\def\RuleB{\vrule depth8pt  width0pt height14pt}
\def\RuleC{\vrule depth10pt width0pt height16pt}

\setlength{\tabcolsep}{0.025\textwidth}%

\vspace{20pt}

\begin{center}
\begin{tabular}{cccc}%
   \noalign{\hrule height 1pt}
   \multicolumn{4}{c}{\RuleC\rmfamily\bfseries%
   Newton-Raphson iterations \quad%
   $x_{n+1} = x_n - f_n/f'_n\ ,\quad f(x) = x-e^{-x}$}\\
   \noalign{\hrule height 1pt}
   \RuleB$ n$&$ x_n$&$ \eps_{n} =  x_{n} - e^{-x_{n}}$&$\eps_{n}/\eps_{n-1}^2$\\
   \noalign{\hrule height 0.5pt}
   \py{table}
   \noalign{\hrule height 1pt}
\end{tabular}
\end{center}

\section*{Example 7}

\input{example-07.pytex}

\bgroup\tt
\begin{tabular}{rl}
   \py{info}
\end{tabular}
\egroup

\end{document}