Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Created June 17, 2012 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zr-tex8r/2943240 to your computer and use it in GitHub Desktop.
Save zr-tex8r/2943240 to your computer and use it in GitHub Desktop.
Value passing between Perl and LaTeX in PerlTeX
\documentclass{article}
\usepackage{perltex}
\begin{document}
\perldo{
$pvalue = 5;
}
\newcounter{tvalue}
\setcounter{tvalue}{6}
\perlnewcommand{\addtopvalue}[1]{
$pvalue += $_[0]; return;
}
\addtocounter{tvalue}{1}
\addtopvalue{1}
\perlnewcommand{\magnifypvalue}[1]{
$pvalue *= $_[0];
return "\\setcounter{tvalue}{$pvalue}";
}
\magnifypvalue{\arabic{tvalue}}
The answer is \arabic{tvalue}.
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment