A dual-monitor setup is convenient for having many windows open simultaneously. For example, it is common to have a LaTeX editor running on one monitor and a viewer for the DVI/PS/PDF output on the other monitor. But sometimes all you have are two separate machines, each with a single monitor. How can you edit a LaTeX document on one machine but have the compiled document display in real time on the second machine, and still have forward-inverse-search work as usual?
Emulating a multi-monitor setup with two or more single-monitor machines is relatively easy to do with xpra, a remote display server and client system. The server and client both work with GNU/Linux, but for the procedure described here, you can use Microsoft Windows or macOS only as a client (i.e., for the PDF viewer).
The following instructions assume that you want to run your LaTeX editor on the machine
desktop and have a PDF viewer display on the machine
desktop machine needs to be running GNU/Linux, but the
laptop machine could be running GNU/Linux, Microsoft Windows, or macOS. The two machines need to be reachable by each other on the network—I assume here that you want xpra to connect the machines via SSH, though if you don't mind the lack of security, xpra can also be used without SSH.
First, install xpra on both machines.
Start an xpra server on
desktopusing a display port of your choice. Type the following on
xpra start :700
desktop's xpra server. Type the following on
xpra attach ssh:username@desktop:700On Microsoft Windows, you might want to invoke the above command with
xprain order to see the logging output. Or you can just run
xprawithout any arguments to launch a connection wizard GUI.
From the command line or from your LaTeX editor running in
desktop, launch your PDF viewer as usual, except have it set the environment variable
DISPLAYwith the value
For example, if you are running Emacs and AUCTeX, you could type
C-c C-c Viewto start launching the viewer, and then manually edit the command line as follows:
DISPLAY=:700 mypdfviewer myfile.pdf
You can repeat from Step 4 if you want to launch several different viewer windows on
laptop. If you have more than two machines, you can repeat from Step 2 using a different display port and launch different viewers on different machines.
When you are done editing, you can run
xpra stop :700 on
desktop to stop the xpra server. The client on
laptop will automatically detach itself.
The nice thing about this method is that it works with SyncTeX's forward-inverse search. For example, with AUCTeX, you can still type
C-c C-v anywhere in your source document on
desktop, and the PDF viewer on
laptop will jump to the corresponding location in the PDF. Conversely, you can shift+click (or control+click, depending on the viewer) in the PDF viewer on
laptop, and the Emacs instance running on
desktop will jump to the corresponding source line.