# Jump to the last line of PDF when Compiling text in Sublime Text

I'm using Sublime text to compile my text file using hotkey Ctrl+b, but when I write pages of equations and compile my file, the pop-up pdf always goes to the first line on the first page. So, I have to scroll down the bar to get to the equation I just wrote. Is there a better way to let the compiled pdf go to the last line? I know, this relates to the sublime text, but I still think sublime text and other latex app share the same thing essentially. Or, you just recommend me to use another latex package from the Github?

This issue is very weird, because it only occurs in this code I attached here. My other tex files do not have this issue when I compile them; namely, the other compiled PDF will go to the line where my cursor in pdf is at.

I'm using Sumatra PDF, and LaTeXTools as plugin.

\documentclass[a4paper]{article}
\usepackage{mathtools}
\usepackage{nccmath}
\usepackage[margin=1in]{geometry}
\usepackage{tikz}

\newcommand \widebox[1]{\setlength\fboxsep{6pt}\boxed {\enspace#1\enspace}}
\newcommand \dpartial[2]{\frac{\partial #1}{\partial #2}}
\newcommand \ddef[2]{\frac{d #1}{d #2}}
\newcommand \spac{\\[0.6em]}
\newcommand \para[1]{\left ( #1  \right )} % Same Size Parathesis
\newcommand \ev [1]{\left\langle #1 \right\rangle}
\newcommand \vbrac [1] {\left [ \,  #1 \, \right ]}
\newcommand{\Mypm}{\mathbin{\tikz [x=1.4ex,y=1.4ex,line width=.1ex] \draw (0.0,0) -- (1.0,0) (0.5,0.08) -- (0.5,0.92) (0.0,0.5) -- (1.0,0.5);}} % New Size of Plus, Minus Sign

\setlength\parindent{0pt}
\numberwithin{equation}{section}

\title{\vspace{-5em} QM Formula List}
\author{David}
\date{}

\begin{document}
\maketitle
\begin{flalign*}
&i\hbar \dpartial{\Psi}{t} = -\frac{\hbar ^2}{2m}\dpartial{^2 \Psi}{x^2}+V\Psi &&\text{Shr\"odinger Equation}\spac
&\widehat{p} = -i \hbar \dpartial{}{x}                                         &&\text{Momentim Operator} \spac
&\widehat{H} = -\frac{\hbar ^2}{2m} \ddef{^2 \psi}{x^2} + V                    &&\text{Energy Operator} \spac \\
&\it{Separable\, Shr\ddot{o}dinger \,Equation} \spac
&-\frac{\hbar^2}{2m}\ddef{^2 \psi}{x^2} + V \psi = E \psi                      &&\text{Time-independent Schr\"odinger Equation} \spac
&\Psi(x,t) = \sum_{n=1}^{\infty} c_{n} \Psi_{n}(x,t)= \sum_{n=1}^{\infty} c_{n} \psi_{n}(x)e^{-iE_{n}t/\hbar} &&\parbox{5.3cm}{General Solution to the Separable Shr\"odinger Equation} \spac \\
&\it{Infinite \, Square \, Well \, of \, Width \, a} \spac
&E_n = \frac{\hbar^2 k_n ^2}{2m} = \frac{n^2 \pi^2 \hbar^2}{2 m a^2}           &&\text{Energy in }  \text{n State} \spac
&\psi_n(x) = \sqrt{\frac{2}{a}}\, \text{Sin}\para{\frac{n \pi}{a} x}           &&\text{Wave Function in} \text{ n State}\spac
&\Psi(x,t) = \sum_{n=1}^{\infty} c_n \sqrt{\frac{2}{a}}\,\text{Sin}\para{\frac{n \pi}{a}x}e^{-i\para{n^2 \pi^2 \hbar/2ma^2}t}
&&\text{General Solution in Linear Combination} \spac
&c_n = \sqrt{\frac{2}{a}} \int_{0}^{a} \text{Sin}\para{\frac{n \pi}{a}x} \Psi(x,0)\,dx &&\text{Constant of n State wave equation} \spac
&\sum_{n=1}^{\infty} |c_n|^2 = 1                                               &&\text{Probability Sum} \spac
&\ev{H} = \sum_{n=1}^{\infty} \, |c_n|^2 \, E_n                                &&\text{Expectation Value of Energy}\spac \\
&\it{The \, Harmonic \, Oscillator} \spac
&a_{\pm} \equiv \frac{1}{\sqrt{2 \hbar m \omega}}\para{\mp ip + m\omega x}   &&\text{Ladder Operator} \spac
&\vbrac{A,B} \equiv AB - BA                                                  &&\text{Commutator Relation} \spac
&\vbrac{x,p} = i\hbar                                                        &&x,p \text{ Relation} \spac
&\vbrac{a_-,a_+} = 1                                                         &&a_-,a_+ \text{ Relation} \spac
&\psi_0 (x) = \para{\frac{m \omega}{\pi \hbar}}^{1/4} e^{- \frac{m \omega}{2 \hbar} x^2} \spac
\end{flalign*}
\end{document}

• Good question. As an aside, I'd recommend you write your equations in some (LaTeX-oriented) two-dimensional editor if you want to see instant output like that. Something like LaTeXiT for OSX; I'm not sure if a Windows analog exists. – Sean Allred Aug 4 '14 at 4:08
• @SeanAllred I know Texmaker can accomplish that, but unfortunately I'm going to only use Sublime Text in windows because I'm really used to Sublime's hotkey. If I use other 2d editor, that does not simplify my problem here. But still thanks your answer! – Lawerance Aug 4 '14 at 4:11
• It would also help to know what PDF viewer you are using and which Sublime plugin you're using to edit LaTeX. – Sean Allred Aug 4 '14 at 4:11
• @SeanAllred I'm using Sumatra PDF. – Lawerance Aug 4 '14 at 4:12
• @SeanAllred LaTeXTools, I'm using. – Lawerance Aug 4 '14 at 4:14

## 1 Answer

What you're asking for is SyncTeX, a editor/viewer agnostic technology that allows the synchronization of views between source files and the compiled about.

Copied from the LaTeXTools README:

You now need to set up inverse search in Sumatra PDF. However, the GUI for doing this is hidden in Sumatra until you open a PDF file that has actual synchronization information (that is, an associated .synctex.gz file): see here. If you have one such file, then open it, go to Settings|Options, and enter "C:\Program Files\Sublime Text 2\sublime_text.exe" "%f:%l" for ST2, and "C:\Program Files\Sublime Text 3\sublime_text.exe" "%f:%l" for ST3, as the inverse-search command line (in the text-entry field at the bottom of the options dialog). If you don't already have a file with sync information, you can easily create one: compile any LaTeX file you already have (or create a new one) with pdflatex -synctex=1 <file.tex>, and then open the resulting PDF file in SumatraPDF.

As an alternative, you can open a command-line console (run cmd.exe), and issue the following command:

sumatrapdf.exe -inverse-search                                             \
"\"C:\Program Files\Sublime Text 2\sublime_text.exe\" \"%f:%l\""


(this assumes that SumatraPDF is in your path; replace 2 with 3 for ST3 of course). I'm sorry this is not straightforward---it's not my fault :-)

Recent versions of MiKTeX add themselves to your path automatically, but in case the build system does not work, that's the first thing to check. TeXlive can also add itself to your path.

Finally, edit the file LaTeX.sublime-settings in the User directory to make sure that the configuration reflects your preferred TeX distribution. Open the file and scroll down to the section titled "Platform settings." Look at the block for your OS, namely windows. Within that block, verify that the texpath setting is correct; for MiKTeX, you can leave this empty, i.e., "". If you do specify a path, note that it must include the system path variable, i.e., \$PATH (this syntax seems to be OK). Also verify that the distro setting is correct: the possible values are "miktex" and "texlive".

TeX Live has one main advantage over MiKTeX: it supports file names and paths with spaces. Furthermore, it is easier to change the compilation engine from the default, pdflatex, to e.g. xelatex: see below for details. (Actually, this is no longer true: a fix for MiKTeX is forthcoming.)

• Ok, I think there is something wrong with one of my particular file because when I compile other text files, it works perfectly fine with them. The compiled PDF will go to the line where my cursor in pdf is at. I'm gonna post my Code for this pdf file. – Lawerance Aug 4 '14 at 4:41
• Also, when I click the any line equation of Sumatra PDF to do the inverse search, the cursor in the text will just go to the line \end{flalign*}, instead of going to the corresponding equation line. – Lawerance Aug 4 '14 at 4:55