# How can I only compile and show a part of an document in TeXStudio

In my special case I want to place a text in a graphic via overpic. It always takes quite long to compile and show the whole document or also even the whole chapter (I think because there are some graphics in it). Is there a possibility that only that one graphic with the text (it's all in an figure section) gets compiled and is shown?

\documentclass[11pt, a4paper, twoside]{scrreprt}
\usepackage[utf8]{inputenc}

\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{overpic}
\usepackage{amssymb}
\usepackage{lmodern}
\usepackage{hyperref}

\begin{document}

\begin{figure}[!h]
\centering
\begin{overpic}
[width=0.3\textwidth]{sample_layout}
\put(40,60){pin1}
\end{overpic}
\caption{scheme}
\label{fig:sample_layout}
\end{figure}

\end{document}

• Could you please explain better? I have understood very little. What would you like to do? Is there an image you could insert, or, even better, a small LaTeX code? – Sebastiano Aug 5 '18 at 20:46
• Why you don't split your code up? – current_user Aug 5 '18 at 20:48
• Play with your graphic in its own file and when you're done copy the thing back into your document. – Skillmon Aug 5 '18 at 20:50
• Presumably you have an \begin{overpic}...\end{overpic} environment? You can try the inline preview (highlight the entire environment, right click and select Preview selection/parenthesis). – Troy Aug 5 '18 at 20:53
• I've already tried that but where can I find the preview then? – vogs Aug 6 '18 at 7:17

You can use inline preview: Highlight the relevant section that you want to compile (here, the overpic environment), right click and select Preview selection. The preview will appear below your code (by default), and updates automatically when you change anything within the preview selection block.

GIF:

(I'm not clicking 'compile' or any other buttons in between the changes you see below in the gif.)

\documentclass{article}
\usepackage{overpic, color}

\begin{document}
\begin{overpic}[abs,unit=1mm,scale=.25,grid]{example-image}
\put(3,15){\color{blue}\huge\LaTeX}
\end{overpic}
\end{document}


Note that this functionality extends to environments like equations, inline math, tables (tabular) etc. as well.

The relevant settings for this can be found in Options -> Configure TeXstudio -> Preview.

As of TXS 2.12.10, TeXstudio uses the preview + varwidth packages for the inline preview functionality mentioned above. preview doesn't play well with floating environments (like figure), so it's best to just stick to previewing non-floating stuff.
For your specific case, it works if you just preview the overpic environment by itself (proof):