Step 1: Create PDF on Server
SSH to your Ubuntu 16.04 server (named connection A) and run:
sudo apt update
sudo apt install texlive-full
sudo apt install evince # if no PDF viewer installed yet
This requires about 3.6GB disk space, and fast Internet connection.
To verify the TeX system, create a demo .tex file and convert to pdf:
cat << EOF > demo.tex
\documentclass[UTF8]{ctexart}
\usepackage{fullpage}
\ctexset{section/format=\Large\bfseries}
\usepackage{graphicx}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{pgf-umlsd}
\usetikzlibrary{shapes.geometric, arrows, positioning}
\tikzstyle{arrow} = [ultra thick, <->, >=stealth]
\usepackage{forest,array}
\usetikzlibrary{shadows}
\title{产品概要设计}
\author{张三,李四}
\date{\today}
\begin{document}
\heiti
\maketitle
\songti
\section{产品需求}
\subsection{业务场景说明}
\subsubsection{典型业务场景}
EOF
xelatex demo.tex
Step 2: View the PDF on Client
On your laptop login to the TeX server via SSH with X server.
For Windows you can use MobaXterm which has a built-in X server as the client,
while for Linux using ssh -X <tex-server>
.
After login via SSH (named connection B), run echo $DISPLAY
,
you get something like localhost:10.0
.
So the DISPLAY attached to you client is :10.0
.
In connection A, run:DISPLAY=:10.0 evince demo.pdf
.
A new window displaying the PDF file should appear on your laptop
in a few seconds, depending on the file size and LAN speed.
Step 3: Editing with Live Preview
On TeX server, install xuhdev/vim-latex-live-preview
plugin for vim
by adding the following lines into .vimrc:
" LaTeX Live Preview
let g:livepreview_engine = 'xelatex'
let g:livepreview_previewer = 'evince'
Plug 'xuhdev/vim-latex-live-preview'
And run PlugInstall
in vim.
Open the file with: DISPLAY=:10.0 evince demo.pdf
,
and run :LLPStartPreview
in the vim.
The PDF window should appear in a few seconds.
While you edit the .tex file, the content in the PDF window will
change accordingly, without saving the source file.
Preview for subfiles structure
If your document has a main-subfiles structure (see Multi-file LaTeX projects for details):
.
├── images
│ └── fig1.png
├── main.tex
├── README.md
└── sections
├── section1.tex
├── section2.tex
├── section3.tex
└── section4.tex
Run vi
in the project root, and run preview command with
:LLPStartPreview main.tex
.
Now your changes in subfiles will refresh the PDF preview window.