0

I have 2 minipages environments inside a tikzpicture environment. The 1st minipage has to have an image on top (fixed size) and the second minipage will have variable size picture. When the 2nd picture gets too big the 1st picture does not stay in the top, it goes center. Anyone can help me?

\begin{minipage}[t]{.1\linewidth}                               
\includegraphics[scale=0.15]{#2}    
\vspace{-.5cm}                      
\end{minipage}

\begin{minipage}[c]{.35\linewidth}                
\centering#3                           
\end{minipage}};%

enter image description here

Bernard
  • 271,350
  • Welcome! There's no tikzpicture in your example. Please can you complete it so we can see what you're doing? Ideally, it should compile to produce the output you show i.e. start \documentclass{... and end \end{document}. This seems to be part of a definition .... – cfr Jul 13 '18 at 23:51
  • \begin{tikzpicture}% \node[rectangle, draw=#1,fill=#1, rounded corners=5pt, inner xsep=5pt, inner ysep=6pt, outer ysep=1pt] {

    \begin{minipage}[t]{.1\linewidth}
    \begin{tabular}{c} \includegraphics[scale=.2]{poliedros.jpg} \ \ \ \end{tabular} \vspace{-.5cm}
    \end{minipage} \begin{minipage}[c]{\linewidth}
    \centering#3
    \end{minipage}};%
    \end{tikzpicture}%

    – Humberto R. Jul 14 '18 at 01:30
  • (1) Please add the code to your question, not as a comment. The code should be a MWE, too. (2) Is the common height of the two minipages fixed and known from the outset, or should it automatically adjust to the size of the 2nd picture? (3) Have a look to this similar question and to its accepted answer. – GuM Jul 14 '18 at 02:35

2 Answers2

1

It seems that OP wants to draw colored boxes to include some text and images. Therefore we could use tcolorboxes.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\begin{document}
\begin{tcolorbox}[colback=brown!70!red, width=.3\textwidth, nobeforeafter, box align=top]
Some text
\end{tcolorbox}
\hfill
\begin{tcolorbox}[colback=yellow!70!brown, width=.6\textwidth, nobeforeafter, box align=top]
\lipsum[1]
\end{tcolorbox}
\end{document}

enter image description here

Ignasi
  • 136,588
0

Latex tries to match the base lines of both minipages. So you can adjust the height/position of the bigger image to the baseline: Measure the height of the first picture in a box (\myimagel). Then set the height of the second picture to the same value by shifting it under the baseline and adding the height of the first picture.

\documentclass{article}
\usepackage{graphicx}

\begin{document}
\thispagestyle{empty}\noindent
%
\newbox\myimagel
\savebox\myimagel{\includegraphics[scale=0.15]{example-image}}%
%
\fbox{\begin{minipage}[t]{.3\linewidth}
    \usebox\myimagel
    Some text.
\end{minipage}}%
%
\newbox\myimager
\savebox\myimager{\includegraphics[scale=0.5]{example-image}}%
\fbox{\begin{minipage}[t]{.5\linewidth}
    \raisebox{\dimexpr\ht\myimagel-\ht\myimager\relax}{\usebox\myimager}
    Some text in here.
\end{minipage}}
\end{document}

result

nox
  • 4,160
  • 12
  • 26