I want to translate the siunitx.pdf to another language, so I have to read the siunitx.dtx and make use of some source code in it. But I have problem to write my own .tex file when I meet the LaTeXdemo environment in the source file. There is a source code segment in siunitx.dtx:
\lstnewenvironment{LaTeXdemo}[1][code and example]
{
\global\let\lst@intname\@empty
\expandafter\let\expandafter\LaTeXdemo@end
\csname LaTeXdemo@#1@end\endcsname
\@nameuse{LaTeXdemo@#1}
}
{\LaTeXdemo@end}
I copy it to my .tex file and write as follows:
\documentclass{article}
\usepackage{listings,siunitx}
\makeatletter
\lstnewenvironment{LaTeXdemo}[1][code and example]
{
\global\let\lst@intname\@empty
\expandafter\let\expandafter\LaTeXdemo@end
\csname LaTeXdemo@#1@end\endcsname
\@nameuse{LaTeXdemo@#1}
}
{\LaTeXdemo@end}
\makeatother
\begin{document}
\begin{LaTeXdemo}
\num{12345,67890} \\
\num{1+-2i} \\
\num{.3e45} \\
\num{1.654 x 2.34 x 3.430}
\end{LaTeXdemo}
\end{document}
However, I don't get the expected result as shown in siunitx.pdf. There is not the corresponding output result. How to solve this problem?

\LaTeXdemois larger, including all the helper macros and definitions it runs from line 191 to line 366 in the currentsiunitx.dtx. – Marijn May 07 '21 at 15:09.texfile but I get the error :! Undefined control sequence. \LaTeXdemo@input->\MakePercentComment.....– Stephen May 07 '21 at 15:24.dtx, make translations in that file, and run LaTeX on the.dtx(see https://tex.stackexchange.com/questions/212776/what-exactly-happens-when-latex-runs-on-a-dtx-file). – Marijn May 07 '21 at 15:31