24

I use LyX 2.0.4 (on Mac OS 10.7) and would like it to do the following:

whenever I hit "View" it should automatically save the pdf output of the lyx file in the same folder the lyx file resides. Whenever I hit "View" again it should overwrite the older version of the pdf. Is that possible?

This is similar to the behavior I know from TeXShop.

3 Answers 3

20

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.

15
  • +1 for the cool idea to implement this on the UI level by a simple command sequence
    – Daniel
    Sep 12, 2012 at 9:17
  • Thanks a for the detailed instructions. Unfortunately after following the steps and hitting view on a file I get the message "SIGSEGV signal caught! Sorry, you have found a bug in LyX..." and thereafter LyX crashes each time I hit view. But the problem dissapears if I delete the stdtoolbars.inc file and undo the setting. Guess I'll have to send a bug report.
    – Michael
    Sep 13, 2012 at 14:43
  • @Michael do you also get that message if you use that command in the mini-buffer? Type alt-x and then paste command-sequence buffer-view; buffer-export pdf2 and press return.
    – scottkosty
    Sep 13, 2012 at 16:18
  • 1
    This site suggests command-sequence buffer-view pdf2 ; buffer-export pdf2 ; It works for me without crash (Lyx 2.1.4, Mac El Capitan)
    – T_T
    Aug 26, 2016 at 7:13
  • 1
    This crash has been fixed as of LyX version 2.3.1 (see lyx.org/trac/ticket/8338).
    – scottkosty
    Jul 13, 2020 at 17:55
10

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.

2
  • I've talked with LyX developers about this and this is the approach they recommend.
    – badp
    May 10, 2013 at 14:31
  • Please don't start answers with "I have the same issue". People might think you don't post a solution but a "me too" post instead. May 11, 2013 at 9:26
4

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.

1
  • This was awesome! What’s the effect of pdf2 in your settings? Omitting it also seems to work…
    – user4929
    Nov 26, 2021 at 11:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .