An idea for collaborative work with LaTeX users

The downside of embedding pdf is that other authors are forced to work in LaTeX too, if I understand well what you are saying.

What do you mean by “other users are forced to use LaTeX”? What I proposed is that TeXmacs allow “including” a LaTeX file and then pass it to the LaTeX engine to produce an embeddable file (I wrote pdf for sake of simplicity).

I did not explain myself well. With the embedded document, the other person who is editing the document (this feature is meant for collaboration) does not have a text encoded in TeXmacs to edit (my statement “other users are forced to use LaTeX” does not make sense, what I had in mind is what I wrote here).

This is easily solved by allowing including a file via its path (this seems to be how TeXmacs treats the bibliography), and TeXmacs file plays a partial role of makefile.

But this is part of the problem with this approach: the only possible output from LaTeX is either DVI or PDF, no other options are possible, so essentially an image. Actually you can already use your method with the current TeXmacs, this is how we implement the TikZ support in the Graphs plugin: we send a LaTeX snipped to LaTeX and import back the PDF, while keeping the LaTeX snipped editable from within TeXmacs. The problem is that page breaking will not work, no other typesetting adjustments, from within TeXmacs the LaTeX output will appear as a black box, or better as a bright image.

Again: I’m not proposing a general solution. I’m trying to work out a feasible solution for a well-defined problem, which is the one I mentioned a couple of times above. I do not think your argument that generically LaTeX users use a wide range of construction is valid in this case: the collaborator will be warned that he cannot use such wide range and just have to stick to agreed constructs. This will be good enough for 80% of cases. For the non-standard cases there is always the possibility to do them in TeXmacs. What is important to me is to have a reliable way to collaborate and produce a normal TeXmacs document. I think I need to experiment a bit with an implementation to make the idea clearer. I see that I’m not getting the message thru very well.

BTW, wouldn’t making this LaTeX variant have flashy features not available in standard LaTeX (e.g., a command for drawing trees) make it more appealing for LaTeX users to try?

1 Like

First, the LaTeX engine will produce several intermediary auxiliary files. They might be analyzed by TeXmacs, and intervene in some way. I know that now we have Graph plugin to embed a PDF, but I don’t see how it could be used to share labels, say.

Next, one could get results other than dvi and pdf. I used tex4ht to produce html files. What I want to say is that, it might be possible to hack the tex engine to produce other formats, just as tex4ht does.

I think that I understand what you want to achieve, but I doubt whether it is useful, i.e., you might simply waste time programming something that others won’t use. I don’t know whether you tried to convince your collaborators. I suppose that, simply asking “could you please only use xxx constructions in LaTeX” will make people unhappy. They think that LaTeX is “what everybody is using” and your restriction seems irrational - and by demanding so, you look unfriendly. It is similar to only allowing one to walk, not to run. Yeah, walking is sufficient for 99% cases, but such a restriction might simply make people unhappy. I speak of this as a young researcher - maybe who I want to cooperate is an expert in a field, and demanding so might tarnish my image.

Perhaps publishing a LaTeX package that does that could be a way: one could write

\usepackage{latexmacs}

in the preamble of their LaTeX file and LaTeX will issue an error if the command is not included in a list of commands accepted by TeXmacs.
Another possibility could be a “guided LaTeX mode” in the TeXmacs editor.

At the same time, one would need to have a TeXmacs package (again called “latexmacs” :wink:) that allows only TeXmacs constructs that can be translated into LaTeX “one-to-one”.
In this way one would generate only documents that can be translated back and forth from TeXmacs to LaTeX and so collaboration would be possible.

2 Likes

For those trying to convince LaTeX users to switch: there’s also a LaTeX conversion block (“Ctrl-\” or “Meta-* l” for me). This turns the code into a TeXmacs tree using the converter. You loose the LaTeX source code once activated, though.


For this, one could also click Edit -> Paste from -> LaTeX.

@jeroen If you want to maintain LaTeX code you can use the plugin in the “evaluation” mode and not session mode, in that case you will have a block like the one you showed but which you can toggle back and forth from the unevaluated to the evaluated form. (Fold->Executable->Graph)

@re4zuaFe having a TeX backend is a possible approach, I see however several major drawbacks: 1) it would require much more effort than the solution I was suggesting
2) it will produce a very low lever representation : all the macros will be expanded, and it will not be possible to generate back a reasonable LaTeX code from the output, also the output cannot be edited in TeXmacs (since it will be too low level) [ps: I might be wrong however, I do not know exactly in details how Tex2ht achieve the conversion]

@re4zuaFe the conversion block is quite similar to paste from LaTeX, except you can compose the LaTeX in TeXmacs, and with undo you can easily make changes if you don’t get the desired output.

@mgubi What I liked about the conversion block is that you get a “live” TeXmacs tree. I’m wondering if it would be possible to turn this into a type of bidirectional fold, with conservative conversion between the LaTeX and TeXmacs representations (but only one is shown at any time). It may be more tractable than a whole document as these blocks are more likely to be limited in extent.

@jeroen this was more or less my idea: to have a well defined subset of LaTeX which can be reliably and (almost) bidirectionaly translated to TeXmacs trees. We could allow some small changes as long as they are stable, that is the LaTeX->TeXmacs->LaTeX conversion has a fixpoint.

1 Like

I think all TeXmacs only commands should be available in this LaTeX variant but with a prefix to single them out as TeXmacs only.

Did you have any issues after the conversion that required fixing manually?

As a reply to “Since ~2015 most of my papers” comment; not sure how to edit the replied post.

Sometimes. Nothing that does not take more than 5 min to fix, just in the last moment before submission. Lately we fixed many of these bugs so now it is even more rare and the conversion is improved constantly as we receive test documents.

This is a StackExchange page with a question on a LaTeX “linter”: https://tex.stackexchange.com/questions/163/is-there-a-program-equivalent-to-lint-for-latex

Among the answers: https://github.com/nspring/style-check

Perhaps one can choose/configure/adapt and obtain a tool to write “LaTeX that can be translated into TeXmacs”.

2 Likes

Actually this is a good idea to implement natively in TeXmacs: a style-checker which normalises common uses. E.g. put a non-breakable space between a word and a following \cite, \eqref, \hlink, etc… tag. Capitalize names, etc… Many people are not aware of these and other well-established style elements and an automatic tool can enforce them. Also it could remove empty tags, etc…

Did you read the LaTeX export to ensure that there is no problem in the conversion (especially, for example, the numbering of the LaTeX and TeXmacs seem different)? I did not read before. Yesterday, I tried one and I find many problems. I have reported the ones that I spotted. I suppose that PhD theses are long, and you might have spotted this kind of problems if you perform a careful comparison.