9

I think I have seen this done before, but I am not sure. Is there a way to build a fake figure in LaTeX? I would like to do this while the other figures in the document render correctly.

Ideally, I would like to have a white box with large text in it, and with a black frame around it. It would be great to be able to control the height and width of this box.

E.g.

\begin{figure}[!t]
\centering
%% Code to make a fake text box
\caption{}
\label{}
\end{figure}

I am loading TikZ in the document, so I can use solutions that may require it.

8

A simple way to do this is to use \fbox{Dummy} with a \resizebox{<width>}{<height>}{<content>}. Maybe playcing the \fbox on the outside.

It is even easier and more flexible with my adjustbox package, e.g.:

\adjustbox{margin=1em,width=.9\textwidth,set height=10cm,frame,center}{Dummy}

\documentclass{article}
\usepackage{adjustbox}
\usepackage{lipsum}

\begin{document}

\lipsum[1]

\begin{figure}[!t]
    \centering
    \adjustbox{margin=1em,width=\textwidth,set height=4cm,set depth=4cm,frame,center}{Dummy}
    \caption{Dummy}
    \label{fig:dummy}
\end{figure}


\lipsum[2-3]

\end{document}

Result

  • 2
    If multi-line text is required add e.g. a minipage=<width> or similar key at the very beginning. – Martin Scharrer Mar 29 '12 at 18:28
  • @AndrewSwann: Yes, thanks. My mistake. Fixed now. – Martin Scharrer Oct 8 '18 at 8:48
5

Another way could be using a \fbox to frame a \parbox (using the second optional argument you can control the height):

\documentclass{article}

\newcommand\FramedBox[3]{%
  \setlength\fboxsep{0pt}
  \fbox{\parbox[t][#1][c]{#2}{\centering\huge #3}}}

\begin{document}

\FramedBox{4cm}{4cm}{Some text}

\FramedBox{2cm}{8cm}{Some text}

\end{document}

enter image description here

4

Here's a way: an \fbox containing invisible rules as high and wide as specified

\newcommand{\fakebox}[2]{% #1 = width, #2 = height
  {\fboxsep=-\fboxrule\fbox{\rule{0pt}{#2}\rule{#1}{0pt}}}}

\fakebox{3cm}{2cm}

The initial setting will add no additional width or height due to the borders.

Adding a word is not difficult: I would never use a large word, just a small one in a corner to make clear that this is only a placeholder

\newcommand{\fakebox}[2]{% #1 = width, #2 = height
  {\fboxsep=-\fboxrule\fbox{\makebox[0pt][r]{\kern2\fboxrule\tiny dummy}%
     \rule{0pt}{#2}\rule{#1}{0pt}}}}
  • There is a \phantombox{<width>}{<height>}{<depth} macro provided by adjustbox, which could be placed in a \frame or \fbox. You can also reduce the dimensions to compensate for the frame rule width and separation. – Martin Scharrer Mar 29 '12 at 18:03
1

My approach is very similar to my solution for this https://tex.stackexchange.com/a/44199/10570 . It uses the picins package.

\documentclass{book}
\usepackage{picins}

\def\pictureBox#1#2#3{%
    \parpic(#1,#2)[d]{#3}\picskip{0}%
}%


\begin{document}
\begin{figure}
\centering
    \pictureBox{8cm}{5cm}{Here is the text.}
    \caption{My placholder}
\end{figure}
\end{document}
0

An other very simple solution may be to use the \missingfigure command of the todonotes package. You can adjust the width and height of the figure with the figwidthand figheight parameters : \missingfigure[figwidth=6cm]{Testing a long text string} You can also change the color of the background with the figheightparameter.

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.