1

I would like to achieve the following: enter image description here

The current code that I have is:

      \scalebox{0.65}{
\begin{minipage}{0.95\textwidth}
    \begin{algorithm}[H]              %new code
        \begin{algorithmic}
    \caption{Example Algorithm}
    \STATE STEP1 
    \STATE STEP2
    \STATE STEP3
    \STATE STEP4


    \end{algorithmic}
  \end{algorithm}
  \end{minipage}%
   }

and putting the remaining text in another minipage. But it doesn't look like the image I want so please give directions. I am ok If instead of arrow, curly bracket comes

gman
  • 1,807
Shreya
  • 25

1 Answers1

1

Here I save the individual boxes and then inset one over the other.

\documentclass{report}
\usepackage{stackengine,xcolor,mathtools}
\begin{document}
\setbox0=\hbox{%
  \fboxsep0pt\fbox{\fboxsep3pt\colorbox{black!10}{\parbox{1.5in}{\parskip 1em
  $D = a + b$\par
  $D = a - b$}}}%
}
\savestack{\graybox}{\box0}
\setbox0=\hbox{\fboxsep3pt\fbox{\parbox{2in}{\parskip 1em
  Example Algorithm:\par
  Step 1\par
  Step 2 $D \xrightarrow{\rule{7ex}{0pt}}$\par
  Step 3\par
  Step 4\par~}}%
}%
\savestack\whitebox{\box0}
\stackinset{c}{65pt}{c}{9pt}{\graybox}{\whitebox}
\end{document}

enter image description here

If rotating the pointing arrow is essential, then this small modification could help:

\documentclass{report}
\usepackage{stackengine,xcolor,mathtools,graphicx}
\begin{document}
\setbox0=\hbox{%
  \fboxsep0pt\fbox{\fboxsep3pt\colorbox{black!10}{\parbox{1.5in}{\parskip 1em
  $D = a + b$\par
  $D = a - b$}}}%
}
\savestack{\graybox}{\box0}
\setbox0=\hbox{\fboxsep3pt\fbox{\parbox{2in}{\parskip 1em
  Example Algorithm:\par
  Step 1\par
  Step 2 $D$ \smash{\rotatebox{-10}{$\xrightarrow{\rule{7ex}{0pt}}$}}\par
  Step 3\par
  Step 4\par~}}%
}%
\savestack\whitebox{\box0}
\stackinset{c}{65pt}{c}{6pt}{\graybox}{\whitebox}
\end{document}

enter image description here

  • Thanks for you answer!! It works perfect!! Can you tell me how to place the grey box at the border of white box as I have added more text. I understand stackinset insert it inside. Is there any other command that can be use to insert stacks ? – Shreya Mar 03 '16 at 13:23
  • Go to http://ctan.org/pkg/stackengine and open the pdf documentation of the stackengine package. Pages 11-12 describe the \stackinset macro (also, pp. 19-20 give examples of nested insets). Basically, first argument is l, c, or r denoting horizontal alignment. 2nd argument is the length offset from that alignment. 3rd and 4th arguments are the same for vertical alignment (t, c, or b). 5th argument is the inset, 6th argument is the base image. – Steven B. Segletes Mar 03 '16 at 13:24
  • Thanks again !! I was able to do!! One more question can I animate the appearance of arrow and grey box in beamer – Shreya Mar 03 '16 at 13:29
  • @ShreyaKhare I am sorry that I am not a user of LaTeX animation. There are other questions on the site that might assist you in that regard, or maybe, if still unclear, you could ask a new question. Best wishes! – Steven B. Segletes Mar 03 '16 at 13:31
  • Is there a way to insert two small grey boxes on the bigger white box – Shreya Mar 03 '16 at 15:04
  • @ShreyaKhare You can nest \stackinset, as described on p.20 of the manual, or here: http://tex.stackexchange.com/questions/171483/mathematical-formulas-on-a-graph-not-made-by-tex/171486#171486 – Steven B. Segletes Mar 03 '16 at 17:02