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}
  • 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
  • 1
    Why you don't split your code up? – current_user Aug 5 '18 at 20:48
  • 2
    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
  • 1
    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
6

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

  • Thanks! Tried that but I always get the following error:Process started: pdflatex.exe -interaction=nonstopmode -ini "&pdflatex hB13868 \dump" Process started: pdflatex.exe -synctex=1 -interaction=nonstopmode "F13868".tex Process exited with error(s) – vogs Aug 7 '18 at 12:38
  • @vogs Please provide the non-working example. If I can't reproduce it, I can't help. – Troy Aug 7 '18 at 12:41
  • Code sample added – vogs Aug 7 '18 at 15:31
  • @vogs see updated answer. don't preview the figure environment, just the overpic environment. it should work. – Troy Aug 7 '18 at 17:15
  • How did you create the animation? – Money Oriented Programmer Dec 24 '18 at 7:04

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.