I write LaTeX in vim, with vim-latex plugin. Is it possible to attach a pdf file with vim so that the pdf file opens with the tex file and closes automatically when I close the tex ?

Currently, I am using this:

servername = "".join(random.choice(string.ascii_lowercase) for _ in range(6))
# if not sys.argv[1].endswith(".tex"):
# inp_tex = sys.argv[1]+".tex"
# oup_pdf = sys.argv[1]+".pdf"
# oup_aux = sys.argv[1]+".aux"
# elif sys.argv[1].endswith(".tex"):
inp_tex = sys.argv[1]
oup_pdf = os.path.splitext(sys.argv[1])[0] + ".pdf"
oup_aux = os.path.splitext(sys.argv[1])[0] + ".aux"

cmdvim = ["gvim", "--servername", servername, inp_tex]

mime = mimetypes.guess_type(inp_tex)
mimetypes.add_type(mime, "tex")
while True:
  print(oup_pdf + " is not yet created")
  if os.path.exists(oup_pdf):
    cmd1 = ["evince", oup_pdf]
cmd2 = ["evince_vim_dbus.py", "GVIM", servername, oup_pdf, inp_tex]

Tha opens the pdf, but does not close it.

I use evince as pdf viewer.

  • I think it should be possible to get something working with autocommands and system(). I suspect it would be reasonably easy to get something that roughly works, and a right pain in the **** to make it robust. – Rich May 14 at 13:32

Your Answer

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

Browse other questions tagged or ask your own question.