0

Does anyone know the command that could export .tex file from my lyx?

I did this because I want to compile tex file with latexmk in terminal since it is really slow to compile in lyx. I feel exhausted that I Haven to click several times whenever I want to export a Tex file. I could create a button to achieve my goal if I know the command.

Thanks in advance.

  • Use Export under "files" – daleif Jun 19 '19 at 11:11
  • Or https://tex.stackexchange.com/questions/405220/exporting-from-lyx-to-latex-including-graphics. – Marijn Jun 19 '19 at 11:23
  • @KJO that is why I did not know exactly which one to choose as duplicate. However, the question which is now marked as duplicate has as second answer https://tex.stackexchange.com/a/3046/ which says lyx --force-overwrite --export pdflatex document.lyx and therefore answers the question, the question in my comment says Go to File->Export->LyX Archive [...] then run another export - this time to LaTeX (pdflatex). This will create a .tex file, which also answers the question here, or should at least be sufficient for the OP to get started. – Marijn Jun 19 '19 at 16:03
  • 1
    @KJO you can probably just put the latexmk command second? Something like lyx --force-overwrite --export pdflatex document.lyx && latexmk document.tex. – Marijn Jun 19 '19 at 16:41
  • @KJO possibly also running lyx --verbose --force-overwrite --export etc. might give some more feedback. – Marijn Jun 19 '19 at 16:44

1 Answers1

1

There are dozens of ways to export from LyX, hence some confusion the most basic is to select the correct format from the drop-down and 9 times out of 10 it will be

EITHER Luatex or simpler pdfLaTeX

HOWEVER you say you want to run in LaTeXmk and there is another choice for that
At the bottom of that really really long list there is a choice of MORE formats and options with yet another long list of Latex types so you can again pick pdfLaTeX and in the bottom box try adding the command options for LaTeXmk (good luck)

enter image description here

Update

As a result of comments It would appear your request for a command to transfer from LyX to LaTeXmk may best be done externally on the command line.

LyX does not show nor confirm any progress however it will convert LyX import to TeX export.

So to get a .tex file from .lyx you need to run a command that will pass its output to Latexmk If using Windows from a command line you use a single & in a cmd file you need to use &&

@Marijn has suggested using

lyx --force-overwrite --export pdflatex document.lyx && Latexmk document.tex  

beware the "force overwrite" is a loose cannon that could accidentally obliterate your master document (you always keep a back-up don't you?)

Note if you are on Linux there was a previous auto compiling system described here. In windows it should be possible for Latexmk to auto convert the lyx to tex then compile to pdf.

  • Thank you for your answer. Is there a way to create a button in the toolbar that could export XeTex file like adding "buffer-export xxxx" to ~/.lyx/ui/stdtoolbars.inc? – Houshou Jun 21 '19 at 04:38