summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/hybrid-latex/examples/example-07.tex
blob: 8c26db4ef89d1f079303a586171793f6a5cbafc4 (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
\documentclass[12pt]{pylatex}
\usepackage{examples}

\begin{document}

\section*{Using tagged blocks}

The following Python code block contains a matched {\tt\small\verb|pyBeg/pyEnd|} pair, with the tag name {\tt\small info}, to capture the output from the formatted Python {\tt\small print} statements.

\begin{minipage}[t]{0.75\textwidth}
\begin{python}
   import platform, datetime
   # pyBeg(info)
   print("date :      &"+'{:%a %d %b %Y %H:%M:%S}'.format(datetime.datetime.now())+"\\\\")
   print("python :    &"+str(platform.python_version())+"\\\\")
   print("system :    &"+str(platform.system())+"\\\\")
   print("release :   &"+str(platform.release())+"\\\\")
   print("machine :   &"+str(platform.machine())+"\\\\")
   print("processor : &"+str(platform.processor())+"\\\\")
   print("platform :  &"+str(platform.platform()))
   # pyEnd(info)
\end{python}
\end{minipage}
\hskip 1cm
\begin{minipage}[t]{0.25\textwidth}
\begin{latex}
   \bgroup\tt
   \begin{tabular}{rl}
      \py{info}
   \end{tabular}
   \egroup
\end{latex}
\end{minipage}

\vspace{12pt}

Here is the output caught from the above block.

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

\end{document}