I have just downloaded TeXmaker ("a free, modern and cross-platform LaTeX editor for linux, macosx and windows systems that integrates many tools needed to develop documents with LaTeX, in just one application") and it has a built-in PDF-viewer which doesn't seem to work. When I make a document, save it, then press watch PDF, it says that the document can't be found. Does anyone know what the problem is and how to fix it?
[Tex/LaTex] Texmaker’s internal pdf-viewer doesn’t work
pdftexmaker
Related Solutions
It would help to know which, if any, LaTeX plugin you're using for vim. (E.g., the latex-suite, vim-auctex, latex-box, etc.)
Next, as far as viewer choice, the only widely used open source PDF viewer for Linux which currently supports SyncTeX well out of the box is Okular. That's probably your best choice.
There are instructions fo setting up SyncTeX with Okular with the vim-latex plugin here, and some related observations here. I had mixed results following those directions. Here's what seems to be important.
Be sure that your LaTeX compilation method (which will depend on your plugin) calls pdflatex (or xelatex or whatever) with the
-synctex=1
flag.I think something like this should suffice for Forward Searches with Okular, though it might be better to try to rewrite or modify the forward search function for your plugin (there's some info on that in one of the links above). Put this in your .vimrc (and change the mapping to whatever you like).
function! SyncTexForward() let execstr = "silent !okular --unique %:p:r.pdf\\#src:".line(".")."%:p &" exec execstr endfunction nmap <Leader>f :call SyncTexForward()<CR>
For reverse searches, set the editor line in Okular to
gvim --servername GVIM --remote +%l %f
. It might also work to usegvim --servername GVIM --remote-send "<Esc>%lgg"
if you only use it with the file already open. Change the servername to whatever you use. (Not sure if it's different with regular vim, but this doesn't make much sense out of a graphical environment.)
I do not have Okular installed right now, however, so I could not test any of that. (And the links I gave earlier have slightly different advice which is worth trying.) I really hope someone with both Okular and gvim installed can test this advice, and correct where I went wrong.
And all of that advice isn't going to work well if you're using subdocuments called through \input{...}
or \include{...}
, where the PDF name doesn't match the name of the document you're editing. There are ways around that, but it would require knowing more about what LaTeX plugins and methods you're already using, if any.
However, other choices are kinda/sorta already available. The next version of evince will support SyncTeX through D-Bus, and apparently someone is already working on a plugin for vim to make use of it. Details here. However, it's very unlikely that this version of evince is already available for your Linux distribution, and there may be some problems with it.
There's an old fork of an old version evince that provides synctex support; there are instructions that come with that detail how to set this up with gvim. It works fine. It's easy to set up if you're using Arch Linux, since this is in the AUR. If you're not, I don't know how hard it would be to compile. (I used to use Ubuntu before Arch, and couldn't get it working there, but that may have been my ignorance.)
Next, I wrote some scripts that provide very limited, very poor, but still better than nothing, synctex support between gvim and the open-source vim-like PDF viewer Zathura, which uses vim-like keybindings. You'll find them mentioned and detailed in this thread in the Arch forums here. (post #370)
Finally, I think this kind of stuff will work its way into the major LaTeX plugins for vim soon, and then you don't have to resort to so much trial and error.
It may sound quite strange, but you have to use exactly the same command as you use to open the external PDF viewer! This is because the code to run the external programs (the function Texmaker::RunCommand
located in texmaker.cpp
, ll.5433-5596 in the sources) checks if the command to be executed is the PDF viewer, and runs the internal viewer instead of the external program if it is activated.
In order to use the internal PDF viewer, you have to select Pdf Viewer->Built-in Viewer
and disable the in the Embed
checkboxOptions->Configure Texmaker->Commands
menu. Now you'll be able to launch Texmaker's viewer by using the same command in the Quick Build->User
input field as stated in Commands->Pdf Viewer->External Viewer
.
No program you use in your Quick Build command line must exit with an error, otherwise the execution will be aborted and the viewer won't be shown.
Best Answer
In TeXmaker you can use the QuickStart menu item to easily create a new document with basic code in place (
\begin{document}
stuff and so on)Then you have to save the document, because it's quite hard to compile a file that hasn't got a filename.
Then you compile the file (use option PDFLaTeX) Then you click on 'View PDF'
Should work...
Afterward you could change the behaviour of Quick Compile to run PDFLaTeX and show the resulting PDF automaticaly.