In my simple example I try to decompose formatting of the text into multiple macro definitions. I use xelatex of miktex disribution to compile it into a pdf.
The question is why does the second %FORM 2 definition doesn't work whereas the %FORM 1 works just fine.
\documentclass{article}
\def\transformrawinput#1,#2,#3,#4 {\textit{#1} \textbf{#2} \underline{#3} #4}
%FORM 1
%\def\finaltransfmormations{\transformrawinput\firstword,\secondword,\thirdword,\forthword \ \rule{\textwidth}{1pt}}
%FORM 2
\def\finaltransfmormations{\transformrawinput{\firstword}{\secondword}{\thirdword}{\forthword} \ \rule{\textwidth}{1pt}}
\def\firstword{one}
\def\secondword{two}
\def\thirdword{four}
\def\forthword{five}
\begin{document}
\finaltransfmormations
\end{document}
Cheers!
Runaway argument?
{\firstword }{\secondword }{\thirdword }{\forthword } \\ \rule {\textwidth \ETC
.
! File ended while scanning use of \transformrawinput.
<inserted text>
\par
<*> ./test_edef_def.tex
?

,in the definition, you need to also do so when calling it. – schtandard Sep 18 '22 at 10:15\defwhen defining latex commands and this issue will not arise. \def is a tex primitive low level definition command and not intended for use in latex (it is not even mentioned in the latex book) – David Carlisle Sep 18 '22 at 10:27#1,#2,#3,#4– David Carlisle Sep 18 '22 at 10:33\def\transformrawinput#1#2#3#4{) but as David mentioned, you are probably better off just using LaTeX commands like\newcommandor\NewDocumentCommand. – schtandard Sep 18 '22 at 10:35