# Solution to use plugins with portable texmacs under windows?

Hello,
First, I apologize for my imperfect English:
I use at home texmacs under ubuntu with its various plugins and everything works relatively well.
In my high school, I use a portable version of texmacs under windows which I have on my usb key.
The downside is that the school network is secure and the texmacs plugins don’t work with my portable version of texmacs.
Only the maxima plugins are recognized and work correctly.
I have a portable version of latex on my key (portable python too), can we get the
other plugins with these portable versions? It sounds complicated.
I am not a programmer. The plugins seem too complicated to me.
I tried the following thing.
I did a test, the image of which is below :

I want to create a “my_latex-pdf” procedure which receives my tex file and then embeds the result (the
pdf file) directly in texmacs.
Below is the first version working when my “rectangle.tex” file is
in the /home/biz folder.
The second version blocks: I put the “rectangle.tex” file in the same folder
than my texmacs file which must contain the image in pdf format. I believe this is the instruction
(system (string-append “pdflatex” " " (fichier_tex name)))) or (system “pdflatex rectangle.tex”) which
don’t work because texmacs tells me that the rectangle.pdf file is not created.

This procedure is tested under my ubuntu and then I will adapt it to my texmacs-portable for windows (
I will be able to use my portable latex version by placing it in a subfolder of texmacs).

Thank you for any responses.

I don’t have the possibility of testing this quickly, but could it be that the Maxima plugin treats file paths differently from the other plugins? I think it is worth checking this before writing one’s own plugin, which I think it is what you are doing

By the way your code looks nice. I think that if you copy-paste the file (or the snippet) in the TeXmacs format it could be easier for others to test it; one now has to re-type everything.

The first version

 (define (fichier_tex name )(string-append name ".tex" ))
(define (fichier_pdf name )(string-append name ".pdf" ))
(define(execute_latex name)(system (string-append "pdflatex" " " "/home/biz/" (fichier_tex name))))
(define(incorpore_pdf name)(make-inline-image (,(string->url (string-append "/home/biz/" (fichier_pdf name))) "200pt" "100pt" "10pt" "10pt")))
(define(mon_latex-pdf name)(begin (fichier_tex name )(fichier_pdf name )(execute_latex name)(incorpore_pdf name)))
(mon_latex-pdf "rectangle")


The second version

(define (fichier_tex name )(string-append name “.tex” ))
(define (fichier_pdf name )(string-append name “.pdf” ))
(define(execute_latex name)(system (string-append “pdflatex” " " (fichier_tex name))))
(define(incorpore_pdf name)(make-inline-image (,(string->url (fichier_pdf name)) “200pt” “100pt” “10pt” “10pt”)))
(define(mon_latex-pdf name)(begin (fichier_tex name )(fichier_pdf name )(execute_latex name)(incorpore_pdf name)))
(mon_latex-pdf “rectangle”)

The file : rectangle.tex

\documentclass[tikz, border = 0cm]{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\draw[thick,blue] (1, 1) rectangle (3, 2) ;
\end{tikzpicture}

\end{document}

Maybe associating your mon-latex-pdf to a keyboard shortcut makes it possible to use it in any place in a document (I did not try it).

It could be interesting posting debug messages that you get when you try and run a plugin that does not work (enable them from the menu with Tools -> Debugging tools and run TeXmacs from a terminal). Maybe someone will be able to interpret them.

I tested your functions and they run. Still it seems to me a very big undertaking to get communications with other programs, perhaps a call to pdflatex is not representative of the amount of work that it takes.

BTW here is your code copied with “Copy to -> TeXmacs”; it can be pasted into a TeXmacs document with “Paste from -> TeXmacs”.

<\session|scheme|default>
<\input|Scheme] >
(define (fichier_tex name )(string-append name ".tex" ))
</input>

<\input|Scheme] >
(define (fichier_pdf name )(string-append name ".pdf" ))
</input>

<\input|Scheme] >
(define(execute_latex name)(system (string-append "pdflatex" " "
(fichier_tex name))))
</input>

<\input|Scheme] >
(define(incorpore_pdf name)(make-inline-image (,(string-\<gtr\>url
(fichier_pdf name)) "200pt" "100pt" "10pt" "10pt")))
</input>

<\input|Scheme] >
(define(mon_latex-pdf name)(begin (fichier_tex name )(fichier_pdf name
)(execute_latex name)(incorpore_pdf name)))
</input>

<\input|Scheme] >
(mon_latex-pdf "rectangle")
</input>

<\input|Scheme] >
\;
</input>
</session>



Note that you can use the “Graph” plugin to access directly pdflatex, you do not have to code yourself in scheme, look at the examples in the help pages of the plugin.

I am aware that my “little program” is very simplistic and I imagine that much more is needed
of work and finesse to make plugins.

However, I do not understand why the second version that I propose does not work on my
ubuntu:
I placed the rectangle.tex file and my test_code.tm file in the same folder
In fact, if I execute in a session scheme (system “pdflatex rectangle.tex”) the file rectangle.pdf
is not created and this causes the sequel to fail.

However, in the terminal, the command: pdflatex rectangle.tex creates the file rectangle.pdf
So it’s a problem with the system statement?

Remark
The graph plugin works and I use it on my ubuntu at home.
I want an alternative solution for my portable version of texmacs (since the plugins can’t work on my high school network)

Pls. try starting TeXmacs from the terminal, in the same directory as the rectangle.tex file.

I’m not sure where the system call runs the command. I would not assume that it runs it in the same directory that the TeXmacs file is. So you need to provide a full path to your tex file.

Est-ce que texmacs possède des commandes qui permettent trouver le chemin du fichier courant de texmacs ?
Merci.

I found in the check-master.scm file the run-pdflatex procedure and it works fine now with

“(define(execute_latex name)(run-pdflatex (file_tex name)))”

The latex file is indeed found in the folder where the current texmacs document is located.
Moreover, we can obviously change the path of pdflatex which will allow me to use my procedure with texmacs portable under windows.

I have one last remark: when we proceed like this (under ubuntu) :
Insert–>Links–>include and we choose a latex file, the drawing appears directly.
This means that a latex command was triggered automatically…maybe it’s also this run-pdflatex procedure. I do not know.
There is a drawback: you can’t resize the resulting image?

Thanks very much.

This is very nice, I did not know it. I saw that the include tag has one argument only, the file path, so I don’t see a way of resizing from TeXmacs.

Hello,
I’m having trouble turning my mon_latex-pdf scheme procedure into a macro for texmacs.
I looked in the documentation:
I created an extern-pascal.scm file (a module if I understood correctly), it contains:

(texmacs-module (extern-pascal))
(define (file_tex name )(string-append name “.tex” ))
(define (file_pdf name )(string-append name “.pdf” ))
(define(execute_latex name)(run-pdflatex (file_tex name)))
(define(embed_pdf name)(make-inline-image (,(string->url (file_pdf name)) “200pt” “100pt” “10pt” “10pt”)))
(tm-define(mon_latex-pdf name)(begin (execute_latex name)(incorporates_pdf name)))

I also created the extern-pascal.ts file which contains :
<use-module|(extern-pascal)>

<assign|latex-pdf|<macro|body|<extern|mon_latex-pdf|<arg|body>>>>

Then for I can load the extern-pascal style into my current texmacs.
I think it’s good so far:
But when I want to use the macro, I get an error at the function argument (which is a path)?

<latex-pdf|“rectangle.tex”>

On the other hand, I tried using the macro action and the procedure works well.
Mais ce n’est pas vraiment ce que je souhaite.

<action|Clic|(mon_latex-pdf “fichier”)>

Thanks for any help you may have.

You have to apply the function tree->stree to the input of the macro. I would try

(tm-define(mon_latex-pdf name)(begin (execute_latex (tree->stree name))(incorporates_pdf (tree->stree name))))


I tried and texmacs crashes with this change.

Ops , sorry.

I didn’t think enough.
It may be because TeXmacs does not “like” inserting document pieces with a macro.
I’ll be able to test the commands in a few days. In the meantime could you please try to associate the command to a keyboard shortcut? Possibly you will need to select the file with a file selector, there is a recent post of @jeroen that shows how to use it within a program.

It is also necessary to check if in this case you need it not tree->stree. I don’t remember. Maybe the file path is used implicitly. It should become clear from @jeroen’s example

Cela devrait devenir clair à partir de l’exemple de @jeroen

I can’t find the article you refer to.
Could I have the link?
Thank you very much for your time spent answering my various questions.

I found the thread at Is it possible to set default size of linked images?

With the smartphone I am very uncomfortable browsing the thread, but if you look inside there is at least one example of the file chooser. Maybe it wasn’t done by @jeroen, who wrote something else in that thread. If so, again sorry about it and let us blame it once more on the limitations of the smartphone

With the file chooser I think you will be able to pass the path implicitly to your functions.

For more detailed explanations I have to postpone till I am again in front of a computer. But hopefully you will manage.