Skip to main content
Post Undeleted by David Carlisle
added 136 characters in body
Source Link
David Carlisle
  • 828.7k
  • 74
  • 1.7k
  • 2.6k

If you look at the file written out you will see there are no values, just \aaa and \bbb as you have prevented expansion with \unexpanded. Removing that enables the values to be written out, you should probably also not use non-immediate writes, but here I force expansion before the call to \foo

enter image description hereenter image description here

\documentclass[a4paper,11pt]{article} \usepackage{ProfLycee} \everymath{\displaystyle} \begin{document} \newwrite\myoutput \immediate\openout\myoutput=\jobname-corr.tex \newcommand{\foo}[2]{%  \write\myoutput{{$\dfrac{#1}{#2}=\noexpand\ConversionFraction{#1/#2}$}} \write\myoutput{\unexpanded{\par \bigskip}} } \textbf{Exercice} : simplify each fraction. \par \bigskip \foreach \n in {1,2,...,5}{ \NbAlea{3}{50}{\aaa} \NbAlea{\aaa+1}{60}{\bbb} $\dfrac{\aaa}{\bbb} = \dfrac{\dots}{\dots}$ \par \bigskip \foo\expanded{\noexpand\foo{\aaa}{\bbb}} \par } \write\myoutput{\textbf{Correction} : \par } \newpage \immediate\closeout\myoutput \input{\jobname-corr.tex} \end{document} 

If you look at the file written out you will see there are no values, just \aaa and \bbb as you have prevented expansion with \unexpanded. Removing that enables the values to be written out

enter image description here

\documentclass[a4paper,11pt]{article} \usepackage{ProfLycee} \everymath{\displaystyle} \begin{document} \newwrite\myoutput \immediate\openout\myoutput=\jobname-corr.tex \newcommand{\foo}[2]{ \write\myoutput{{$\dfrac{#1}{#2}=\noexpand\ConversionFraction{#1/#2}$}} \write\myoutput{\unexpanded{\par \bigskip}} } \textbf{Exercice} : simplify each fraction. \par \bigskip \foreach \n in {1,2,...,5}{ \NbAlea{3}{50}{\aaa} \NbAlea{\aaa+1}{60}{\bbb} $\dfrac{\aaa}{\bbb} = \dfrac{\dots}{\dots}$ \par \bigskip \foo{\aaa}{\bbb} \par } \write\myoutput{\textbf{Correction} : \par } \newpage \immediate\closeout\myoutput \input{\jobname-corr.tex} \end{document} 

If you look at the file written out you will see there are no values, just \aaa and \bbb as you have prevented expansion with \unexpanded. Removing that enables the values to be written out, you should probably also not use non-immediate writes, but here I force expansion before the call to \foo

enter image description here

\documentclass[a4paper,11pt]{article} \usepackage{ProfLycee} \everymath{\displaystyle} \begin{document} \newwrite\myoutput \immediate\openout\myoutput=\jobname-corr.tex \newcommand{\foo}[2]{%  \write\myoutput{{$\dfrac{#1}{#2}=\noexpand\ConversionFraction{#1/#2}$}} \write\myoutput{\unexpanded{\par \bigskip}} } \textbf{Exercice} : simplify each fraction. \par \bigskip \foreach \n in {1,2,...,5}{ \NbAlea{3}{50}{\aaa} \NbAlea{\aaa+1}{60}{\bbb} $\dfrac{\aaa}{\bbb} = \dfrac{\dots}{\dots}$ \par \bigskip \expanded{\noexpand\foo{\aaa}{\bbb}} \par } \write\myoutput{\textbf{Correction} : \par } \newpage \immediate\closeout\myoutput \input{\jobname-corr.tex} \end{document} 
Post Deleted by David Carlisle
Source Link
David Carlisle
  • 828.7k
  • 74
  • 1.7k
  • 2.6k

If you look at the file written out you will see there are no values, just \aaa and \bbb as you have prevented expansion with \unexpanded. Removing that enables the values to be written out

enter image description here

\documentclass[a4paper,11pt]{article} \usepackage{ProfLycee} \everymath{\displaystyle} \begin{document} \newwrite\myoutput \immediate\openout\myoutput=\jobname-corr.tex \newcommand{\foo}[2]{ \write\myoutput{{$\dfrac{#1}{#2}=\noexpand\ConversionFraction{#1/#2}$}} \write\myoutput{\unexpanded{\par \bigskip}} } \textbf{Exercice} : simplify each fraction. \par \bigskip \foreach \n in {1,2,...,5}{ \NbAlea{3}{50}{\aaa} \NbAlea{\aaa+1}{60}{\bbb} $\dfrac{\aaa}{\bbb} = \dfrac{\dots}{\dots}$ \par \bigskip \foo{\aaa}{\bbb} \par } \write\myoutput{\textbf{Correction} : \par } \newpage \immediate\closeout\myoutput \input{\jobname-corr.tex} \end{document}