2

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}

1 Answers1

8

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.)

enter image description here

\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.


Addendum

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.

The 'error' that you receive when you try to inline preview a floating environment is the well-known "not in outer par mode" error.

For your specific case, it works if you just preview the overpic environment by itself (proof):

enter image description here

Troy
  • 13,741