Can LyX automatically save the PDF output in the same folder?

The following should work on LyX >= 2.3.1 for all operating systems:

First go to Tools > Preferences > Output and change "Overwrite on export" to "All files". Make sure you know what that means and that you are comfortable with that. Apply that preference change.

Then go to Help > About to find out where your "Library directory" and "User directory" are. For example, mine are

library directory: /usr/share/lyx

and

user directory: ~/.lyx/

Navigate (e.g. in your file browser) to your library directory and go to the ui folder and copy stdtoolbars.inc to the ui folder of your user directory. So in my case I copied /usr/share/lyx/ui/stdtoolbars.inc to ~/.lyx/ui/stdtoolbars.inc

Now edit stdtoolbars.inc in your user directory: You want to edit the line below

Toolbar "view/update" "View/Update"

Change

Item "View" "buffer-view"

to

Item "View" "command-sequence buffer-view pdf2; buffer-export pdf2"

If you want to know more, read the LyX help guides in the Help menu for more customization.


Alternative workaround: map buffer-export pdf2 to a keyboard shortcut in Editing->Shortcuts in Preferences.

How to use it: Preview in OS X (and many other pdf viewers as well) will update open pdf's whenever they are changed, so, if you just run the export command once and then open the pdf and leave it open, every time you run the export command again the pdf will get updated. I usually have my windows arranged such that I can see LyX and Preview at the same time, so this works out almost as well as having LyX actually open the pdf (like it does when you run the "View" command -- which somehow renders and opens the pdf without crashing LyX...).

Why use this method: As was the case for Michael, in OS X LyX randomly crashes when I try to do command-sequence buffer-view; buffer-export pdf2 as suggested by @scottkosty. It seems that some other users are able to use the sequence without crashing, so it might be best try that first. The workaround given here isn't exactly what Michael asked for because LyX does not open the pdf, but it is the closest I have been able to get that works without crashing.


This only changes the behaviour for the keyboard shortcut, not the gui icon. It's easier and maybe all you need.

First go to Tools > Preferences > Output and change "Overwrite on export" to "All files". Make sure you know what that means and that you are comfortable with that.

Then go to Tools > Preferences > Editing > Shortcuts, search for buffer-view Ctr-R, click modify and replace buffer-view with command-sequence buffer-view pdf2; buffer-export pdf2.

Tags:

Lyx