Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Featurerequest: \inputmpcode #107

Open
Reissner opened this issue Apr 5, 2023 · 4 comments
Open

Featurerequest: \inputmpcode #107

Reissner opened this issue Apr 5, 2023 · 4 comments

Comments

@Reissner
Copy link

Reissner commented Apr 5, 2023

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.

@dohyunkim
Copy link
Contributor

dohyunkim commented Apr 6, 2023

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.

@Reissner
Copy link
Author

Reissner commented Apr 6, 2023

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?

@dohyunkim
Copy link
Contributor

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.

@Reissner
Copy link
Author

Reissner commented Apr 8, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants