0

I have a text and I want to highlight it with a kind of portrait like in the below image:

enter image description here

I mean, instead of writing "Placeholder/Image" I want to add my text in that kind of window with possibly other color.

Is it possible to do that in LaTeX? and How?

Thanks in advance for your help.

  • Short answer: Yes. – Johannes_B Oct 8 '16 at 16:49
  • jajaja right :) but How do you do that ? – user162343 Oct 8 '16 at 16:50
4

EDITED to transition automatically to a \parbox if width exceeds 2in.

\documentclass{article}
\usepackage{stackengine,xcolor}
\newcommand\specbox[3][black]{\bgroup%
  \color{#1}%
  \fboxsep=1.7ex\relax%
  \setstackgap{S}{1.3ex}%
  \setbox0=\hbox{\stackanchor{#2}{#3}}%
  \ifdim\wd0>2in\relax%
    \fbox{\Shortstack{{\parbox{2in}{\centering #2}} {%
    \rule{1.6in}{.5pt}} {\parbox{2in}{\centering #3}}}}%
  \else%
    \fbox{\Shortstack{{#2} {\rule{\dimexpr\wd0-1em}{.5pt}} {#3}}}%
  \fi%
\egroup}
\begin{document}
\specbox[red]{Placeholder}{Image}

\specbox[green!50!black]{This is a test of the EBS}{this is only a test}

\specbox[blue]{This is a test of the Emergency Broadcast System}
  {this is only a test}
\end{document}

enter image description here

| improve this answer | |
  • Right ;), let me try that. – user162343 Oct 8 '16 at 16:52
  • Why does it appears "long"? A mean like a rectangle instead of a square, Is it because the amount of words that I put? – user162343 Oct 8 '16 at 16:59
  • @user162343 Yes. If you want the words stacked, you could make the argument a \parbox. If you always wanted it of a fixed width, then that is possible, too. But you were too vague in your question, so I had to make some guesses as to your intent. I may revise to show more possibilities. – Steven B. Segletes Oct 8 '16 at 17:03
  • Sorry :) for that, the thing is that I want it varies the length so that I can write a considerable amount of information please :) – user162343 Oct 8 '16 at 17:05
  • @user162343 Please look at my revision that transitions to multiline if the text width is greater than 2in. – Steven B. Segletes Oct 8 '16 at 17:12
2

More than one way possible.

texsxPlaceholder

\documentclass[twocolumn]{article}
\usepackage{todonotes}
\usepackage{blindtext}
\newcommand{\placeholder}{%
    \framebox{\parbox{.9\linewidth}{\centering\huge\color{red!60!black}\itshape
    Placeholder\par
    \rule[.5ex]{.6\linewidth}{.8pt}\par
    Wombat
}}}
\begin{document}
\blindtext
\begin{figure}
    \placeholder
\end{figure}
\blindtext
\begin{figure}
    \includegraphics[width=.8\linewidth]{example-image}
\end{figure}
\blindtext

\begin{figure}
    \missingfigure[figwidth=\linewidth]{A figure is missing here}
\end{figure}
\end{document}
| improve this answer | |
  • Let me just try that, right? Thnks – user162343 Oct 8 '16 at 17:04
  • I liked the idea of the text that says "missing figure" but How does the \begin{figure} command acts because I have already wrote and it did nothing. Thanks in advance :) – user162343 Oct 8 '16 at 17:10
  • 1
    @user162343 The figure environment places everything inside it to a suitable place. Pleas have a look at a LaTeX introduction. – Johannes_B Oct 8 '16 at 17:13
  • Right, the thing is that I thought that whenever I write something inside that command it would appear in the gray square that you drew :) – user162343 Oct 8 '16 at 17:14
  • @user162343 Package todonotes draws that grey box. It wasn't me. ;-) – Johannes_B Oct 8 '16 at 17:22

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.