I know in Texstudio the embedding PDF viewer can be closed using Esc and will appear again if I hit F7 key and it can also be expanded. Is it possible to write a macro script for which whenever I start writing in the editor the PDF viewer will be automatically closed and will appear in the extended view after the compilation?
It's possible to use macro script to close the pdf viewer automatically, following a keypress trigger. The pdf viewer opening after compilation can be set as part of your build sequence.
To close PDF viewer automatically
Create a new script with the following:
if (pdfs.length > 0)
with the trigger set to whatever you like. Suppose you want the viewer to be closed after typing one of the 26 (small) letters in the English alphabet, then set trigger to
- I'm not sure whether this introduces any lag/latency when typing large files (since the script is checking whether the viewer is open almost every keypress you make).
- This does not work when the completer is open. For example, if you are typing
\sect, then the completer pops up to suggest
\section, then the trigger will not be active and thus the script will not run. This is well documented in the User Manual Section 18.104.22.168. Just continue typing until the autocompleter closes, then the trigger will work as per normal after that.
- And honestly, I think this behaviour is extremely jarring and distracting, but if that's what you want. :)
Note: The trigger can take other values also, so suppose you have:
[a-zA-Z0-9:.,?!] % Set as the trigger
then the script will trigger for all 26 letters of the English alphabet (capitalized and non-capitalized), all numbers, and some of the punctuation symbols. Look up 'Regular Expression', or 'regex' for more information.
To Open PDF viewer automatically
This should be the default behaviour of TeXstudio, so just click the shortcut for Build & View (F5).