1

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?

1

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 laptop. The 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.

  1. First, install xpra on both machines.

  2. Start an xpra server on desktop using a display port of your choice. Type the following on desktop: xpra start :700

  3. Next, have laptop attach to desktop's xpra server. Type the following on laptop: xpra attach ssh:username@desktop:700 On Microsoft Windows, you might want to invoke the above command with xpra_cmd rather than xpra in order to see the logging output. Or you can just run xpra without any arguments to launch a connection wizard GUI.

  4. 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 DISPLAY with the value :700.

    For example, if you are running Emacs and AUCTeX, you could type C-c C-c View to 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.

  • isn't this description only for people using X11?, the xpra page that you link to says that it can only forward the entire desktop on mac and windows not individual applications as set by DISPLAY – David Carlisle Sep 21 '17 at 20:57
  • @DavidCarlisle: You're right; forwarding single applications works only with the GNU/Linux server. I have updated the answer accordingly. – Psychonaut Sep 22 '17 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.