1

I have a really heavy tex file that i'm still working on. Every time a start my computer and open for 1st time the tex file with TexStudio I have to compile it in order to view the PDF, even when the PDF file already exist. This annoying specially because it takes a long time to compile. TexShop on mac for example automatically opens the PDF associated with the tex file at startup. Is there a way to achieve this with TexStudio on windows?

4
  • 3
    I use it on Linux, but I suppose it's the same. There is a toolbar icon, three to the right of "Build and compile", which is "View". That will show you the previously compiled pdf. Alternatively, on the menu "Tools" -> "View", or just F7.
    – gusbrs
    Apr 19, 2017 at 23:50
  • ok, that allows me to view it with out compile, now I only need to write a script to make texStudio do that every time i open a .tex file. Thanks.
    – Jared Lo
    Apr 19, 2017 at 23:56
  • Do you have Restore Previous Session at Startup enabled i.stack.imgur.com/D8HPx.png? When I open texstudio my existing pdf is automatically displayed. Another solution: use latexmk, it automatically determines if the pdf needs to be recompiled. Apr 20, 2017 at 15:45
  • @Troy, it's done.
    – gusbrs
    Dec 13, 2017 at 9:53

2 Answers 2

4

I use TeXstudio on Linux, but I suppose it's the same. There is a toolbar icon, three to the right of "Build and compile", which is "View". Alternatively, on the menu "Tools" -> "View", or just F7. These will show you the previously compiled pdf, once you are within TeXstudio.

As mentioned by samcarter in the comments, TeXstudio has an option to "Restore previous session at startup" which does what the name says, and automatically shows the pdf of open files. TeXstudio also displays the pdf on the viewer of a newly opened file, provided it had been previously compiled.

To access the "Restore previous session at startup" go to "Options -> Configure TeXstudio", check "Show advanced options" on the left bottom corner. The option is then available in the "General" tab.

3

@gusbrs already provided solutions for manually activating the View PDF function in TeXstudio, I'll just extend it to automatically display PDF whenever the .tex file is loaded/opened.


On a per-file basis, you can get TXS to automatically display the PDF (if it exists) using a magic comment TXS script (read more here). Paste the following code at the top of the .tex files you want TeXstudio to display the corresponding PDF for, above the usual document code. For example:

main.tex

% !TeX TXS-SCRIPT = viewpdf
% //Trigger = ?load-this-file 
% app.getManagedAction("main/tools/view").trigger();
% TXS-SCRIPT-END

% ------------------------ Example document below!
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
 Hello world.
\end{document}

Then whenever main.tex is loaded in TXS, main.pdf will automatically display in the PDF viewer.

This might be a bit cumbersome, so if you would like this behaviour, by default (i.e., for all .tex files you open), then you can create a very basic user macro, under Macros -> Edit Macros -> Add.

Set the trigger as: ?load-file, and main script as:

%SCRIPT
app.getManagedAction("main/tools/view").trigger();

enter image description here

No keypress is required to activate this.

1
  • 1
    That's a neat tweak! (+1)
    – gusbrs
    Dec 13, 2017 at 17:34

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.