Created
November 16, 2011 23:20
-
-
Save rbonvall/1371840 to your computer and use it in GitHub Desktop.
Listings with named ranges using pgf's \foreach doesn't work
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # P1 | |
| s = {78, 15, 91, 15} | |
| print len(s) | |
| # FIN P1 | |
| # P2 | |
| d = {78: 15, 91: 15} | |
| print len(d) | |
| # FIN P2 | |
| # P3 | |
| n = (17, 3, 1993) | |
| h = (14, 5, 2011) | |
| print n < h | |
| # FIN P3 | |
| # P4 | |
| x, y = ((27, 3), 9) | |
| z, w = x | |
| print y + w | |
| # FIN P4 | |
| # P5 | |
| a = 'acabase' | |
| b = set(a) | |
| c = list(b) | |
| c.sort() | |
| print c[2] | |
| # FIN P5 | |
| # P6 | |
| t = 'papagayo' | |
| w = t.split('a') | |
| print w[3] | |
| # FIN P6 | |
| # P7 | |
| def f(a, b): | |
| return a + 2 * b | |
| a = 5 | |
| b = 2 | |
| print f(b, a) | |
| # FIN P7 | |
| # P8 | |
| def f(a): | |
| return x + a | |
| def g(x): | |
| return x + a | |
| x = 5 | |
| a = 7 | |
| print f(x) + g(x) | |
| # FIN P8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \documentclass{article} | |
| \usepackage{listings} | |
| \usepackage{pgffor} | |
| \usepackage{courier} | |
| \lstset{basicstyle=\ttfamily} | |
| \lstset{language=python} | |
| \lstset{rangeprefix=\#\ } | |
| \lstset{includerangemarker=false} | |
| \begin{document} | |
| \foreach \x in {1,2,...,8} { | |
| \noindent | |
| \begin{minipage}[b]{19.8em} | |
| \lstinputlisting[linerange=P\x-FIN\ P\x]{programas.py} | |
| % \lstinputlisting[linerange=P1-FIN\ P1]{programas.py} % This works | |
| \framebox[18em]{\rule[6ex]{0pt}{0pt}} | |
| \vspace{0.7em} | |
| \end{minipage} | |
| } | |
| \end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment