Created
October 31, 2013 17:52
-
-
Save zr-tex8r/7254018 to your computer and use it in GitHub Desktop.
LaTeX: Doing (or not doing) Python with PythonTeX
This file contains 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
% 文字コードは一応UTF-8 | |
\documentclass[a4paper]{jsarticle} | |
\usepackage{pythontex} | |
\usepackage{type1cm} | |
\newcommand*{\textFunny}[1]{% | |
{\usefont{OT1}{cmfr}{m}{it}\LARGE #1}% | |
} | |
\newcommand{\NabeAzz}[1]{% | |
\pyc{nabeazz(#1)}% | |
} | |
\begin{pycode} | |
def nabeazz(n): | |
for i in range(1, n + 1): | |
if i % 3 == 0 or '3' in str(i): | |
print(r"\textFunny{%d}" % i) | |
else: | |
print(i) | |
\end{pycode} | |
\begin{document} | |
3の倍数と3が付く数字のときだけFunnyになります。 | |
\begin{quote} | |
\NabeAzz{40} | |
\end{quote} | |
\end{document} |
This file contains 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
% 文字コードは一応UTF-8 | |
\documentclass[a4paper]{jsarticle} | |
\usepackage[usefamily=ruby]{pythontex} | |
\usepackage{type1cm} | |
\newcommand*{\textFunny}[1]{% | |
{\usefont{OT1}{cmfr}{m}{it}\LARGE #1}% | |
} | |
\newcommand{\NabeAzz}[1]{% | |
\rubyc{nabeazz(#1)}% | |
} | |
\begin{rubycode} | |
def nabeazz(n) | |
1.upto(n).each do |i| | |
puts((i % 3 == 0 || i.to_s =~ /3/) ? "\\textFunny{#{i}}" : i) | |
end | |
end | |
\end{rubycode} | |
\begin{document} | |
3の倍数と3が付く数字のときだけFunnyになります。 | |
\begin{quote} | |
\NabeAzz{40} | |
\end{quote} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment