Open Reissner opened 1 year ago
Why don't you use TeX's expansion functionality.
\newcommand*\inputmpcode[1]{\begin{mplibcode}input #1.mp\end{mplibcode}}
...
\inputmpcode{mympfile}
The above definition at first line can go into luamplib.cfg
as well.
as such a good idea... but i feel i prefer a standardized way to do it. If I depend on a config, it is not portable. When I send a file to someone with just standard texlive with luamplib installed, it should work without config.
but just to test luamplib.cfg: shall it be in the package directory?
as such a good idea... but i feel i prefer a standardized way to do it. If I depend on a config, it is not portable. When I send a file to someone with just standard texlive with luamplib installed, it should work without config.
Then the definition can go into .tex file.
but just to test luamplib.cfg: shall it be in the package directory?
Anywhere lualatex can read it is OK. In this respect, it is not different from other .tex or .sty files. The local directory is also OK, as a matter of course.
I think, one shall in general avoid pollution the local directory with files. Also, an installation shall be plain to keep reproducibility. The best alternative if you don't follow my suggestion is writing the command into the tex file.
I think that the authors of the listings package added the according command was a good decision. I think it would be frequently used and avoids for the user to write the definition over and over into a tex file. Realization is very simple.
The idea is stolen from latex package 'listings': it provides a command
\lstinputlisting{...}
, which allows to read in a file containing the listing. So the file can be run and printed in parallel.I would suggest to complement the environment
mplibcode
with the command\inputmcode
reading in an mp file and executing it. That way one could avoid mixing tex and mp in a single file. I have highlighter in my editor which get confused, if i to not separate the two languages.