1

i want to create 3 box side by side like attachment image. Please help

My code:

%\documentclass[a4paper]{article}
\documentclass[a4paper]{book}
\usepackage{amsmath,amssymb}%      pour les maths
\usepackage{enumitem}
\usepackage{wrapfig}
\usepackage{graphicx}
\usepackage{MnSymbol,wasysym}
\usepackage[svgnames]{xcolor}
\usepackage[most]{tcolorbox}
\usepackage{framed}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[utf8]{vietnam}
%\usepackage[utf8]{english}
\usepackage[english]{babel}
\usepackage[format=plain,
            labelfont={bf,it},
            textfont=it]{caption}

%\newcommand\captionof[2]{\def\@captype{#1}\caption}

\usepackage{tikzsymbols} 
\newtcbtheorem{myLemma}{Long text here without counter }{lemmastyle}{thm}

\usetikzlibrary{calc, fit, backgrounds}
\usepackage{varwidth}
\newcommand{\mybox}[4][\textwidth-\pgfkeysvalueof{/pgf/inner xsep}-2mm]{%
%\begin{figure}[!h]
\centering
\begin{tikzpicture}
\node[line width=0.5mm, inner ysep=10pt, text width=#1, outer sep=0] (text) {\begin{varwidth}{\textwidth}#4\end{varwidth}};
\node[text=white, above right, align=left] (title) at (text.north west) {#3};
\node[fit=(title) (text), line width=0.5mm, rounded corners, draw=#2, inner sep=0pt] (box){};
\begin{scope}[on background layer]
\fill[#2] (title.south west) -- (title.south east) to[out=0, in=180] ([xshift=1.5cm]title.east) -- (title.east-|box.north east) [rounded corners] -- (box.north east) -- (box.north west) [sharp corners] -- cycle;
\end{scope}
\end{tikzpicture} 
%\end{figure}
}

\usepackage{pifont}

\begin{document}

\tcbset{sidebyside,
  size=minimal,
  colback=white,
  lower separated=false,
  halign upper=flush center,
  halign lower=flush left,
  lefthand width=2.5cm, 
  frame empty,
}



\begin{tabular}{cccc}
\mybox[10cm]{green!70!black}{Eat That Frog | Related }{
\begin{enumerate}
\item ....................................................\hspace*{1cm}..........................

\item ....................................................\hspace*{1cm}..........................

\end{enumerate}
}
%\hspace*{1cm}
&
\mybox[3cm]{green!30!black}{Mood}{
 \hspace*{0.2cm} \dLaughey[2.0] \hspace*{0.5cm} \dNeutrey[2.0] \hspace*{0.5cm}  
 \\
 %\vspace*{1cm} \quad
%\vspace{0.2in}
 \hspace*{0.2cm} \dInnocey[2.0] \hspace*{0.5cm} \dWalley[2.0] \hspace*{0.5cm}
 }


\end{tabular}

\begin{tabular}{cccc}
\mybox[10cm]{blue!70!black}{ Appointments | When | With | Where}{
\begin{enumerate}
\item .....................................  .... : ....        .....................      ..................

\item .....................................  .... : ....        .....................      ..................

\end{enumerate}
}
&
\mybox[3cm]{green!30!black}{Drink up}{
 \hspace*{0.2cm} \bigcup \hspace*{0.2cm} \bigcup \hspace*{0.2cm}  \bigcup \hspace*{0.2cm}  \bigcup \hspace*{0.2cm}  \bigcup \hspace*{0.2cm}
 \\
 %\vspace*{1cm} \quad
%\vspace{0.2in}
 \hspace*{0.2cm} \bigcup \hspace*{0.2cm} \bigcup \hspace*{0.2cm}  \bigcup \hspace*{0.2cm}  \bigcup \hspace*{0.2cm}  \bigcup \hspace*{0.2cm}
 }
\end{tabular}



\end{document}
1

This uses \smash to hide the height of the right box from the tabular. It basically overlays the missing cell from the first row.

I used saveboxes to measure the heights of the tikzpictures (depths=0). The tabular adds \arratystretch\dp\strutbox between the two. Finally one has to subtract the inner xsep (times 2) and the linewidth to get the needed text width.

BTW, these boxes are far too wide for the page.

%\documentclass[a4paper]{article}
\documentclass[a4paper]{book}
\usepackage{amsmath,amssymb}%      pour les maths
\usepackage{enumitem}
\usepackage{wrapfig}
\usepackage{graphicx}
\usepackage{MnSymbol,wasysym}
\usepackage[svgnames]{xcolor}
\usepackage[most]{tcolorbox}
\usepackage{framed}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[utf8]{vietnam}
%\usepackage[utf8]{english}
\usepackage[english]{babel}
\usepackage[format=plain,
            labelfont={bf,it},
            textfont=it]{caption}

%\newcommand\captionof[2]{\def\@captype{#1}\caption}

\usepackage{tikzsymbols} 
\newtcbtheorem{myLemma}{Long text here without counter }{lemmastyle}{thm}

\usetikzlibrary{calc, fit, backgrounds}
\usepackage{varwidth}
\newcommand{\mybox}[4][\textwidth-\pgfkeysvalueof{/pgf/inner xsep}-2mm]{%
%\begin{figure}[!h]
\centering
\begin{tikzpicture}
\node[line width=0.5mm, inner ysep=10pt, text width=#1, outer sep=0] (text) {\begin{varwidth}{\textwidth}#4\end{varwidth}};
\node[text=white, above right, align=left] (title) at (text.north west) {#3};
\node[fit=(title) (text), line width=0.5mm, rounded corners, draw=#2, inner sep=0pt] (box){};
\begin{scope}[on background layer]
\fill[#2] (title.south west) -- (title.south east) to[out=0, in=180] ([xshift=1.5cm]title.east) -- (title.east-|box.north east) [rounded corners] -- (box.north east) -- (box.north west) [sharp corners] -- cycle;
\end{scope}
\end{tikzpicture}}

\usepackage{pifont}

\begin{document}

\tcbset{sidebyside,
  size=minimal,
  colback=white,
  lower separated=false,
  halign upper=flush center,
  halign lower=flush left,
  lefthand width=2.5cm, 
  frame empty,
}

\sbox0{\mybox[10cm]{green!70!black}{Eat That Frog | Related }{%
\begin{enumerate}
\item ....................................................\hspace*{1cm}..........................

\item ....................................................\hspace*{1cm}..........................

\end{enumerate}
}}%
\sbox1{\mybox[10cm]{blue!70!black}{ Appointments | When | With | Where}{
\begin{enumerate}
\item .....................................  .... : ....        .....................      ..................

\item .....................................  .... : ....        .....................      ..................

\end{enumerate}
}}%

\begin{tabular}{@{}cc@{}}
  \usebox0 & \\
  \usebox1 & \smash{\rotatebox[origin=bl]{90}{% 
  \mybox[\dimexpr \ht0+\ht1+\arraystretch\dp\strutbox-0.666em-0.5mm]% inner xsep=0.333em, linewidth=0.5mm (half in)
    {green!30!black}{Mood}{ \hspace*{0.2cm} \dLaughey[2.0] \hspace*{0.5cm} \dNeutrey[2.0] \hspace*{0.5cm} \\ %
    \vspace*{1cm} \quad %
    \vspace{0.2in} \hspace*{0.2cm} \dInnocey[2.0] \hspace*{0.5cm} \dWalley[2.0] }% 
}} 
\end{tabular} 


\end{document}

I can't figure out why you are using varwidth, other than it eats the extra space above and below enumerate (like minipage). Setting text width already puts the text into a \parbox. I replaced it here so I could use \hfil and \centering.

%\documentclass[a4paper]{article}
\documentclass[a4paper]{book}
\usepackage{amsmath,amssymb}%      pour les maths
\usepackage{enumitem}
\usepackage{wrapfig}
\usepackage{graphicx}
\usepackage{MnSymbol,wasysym}
\usepackage[svgnames]{xcolor}
\usepackage[most]{tcolorbox}
\usepackage{framed}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[utf8]{vietnam}
%\usepackage[utf8]{english}
\usepackage[english]{babel}
\usepackage[format=plain,
            labelfont={bf,it},
            textfont=it]{caption}

%\newcommand\captionof[2]{\def\@captype{#1}\caption}

\usepackage{tikzsymbols} 
\newtcbtheorem{myLemma}{Long text here without counter }{lemmastyle}{thm}

\usetikzlibrary{calc, fit, backgrounds}
\usepackage{varwidth}
\newcommand{\mybox}[4][\dimexpr \textwidth-\pgfkeysvalueof{/pgf/inner xsep}-\pgfkeysvalueof{/pgf/inner xsep}-1mm]{%
%\begin{figure}[!h]
\centering
\begin{tikzpicture}
\node[line width=0.5mm, inner ysep=10pt, outer sep=0] (text) {\begin{minipage}{#1}#4\end{minipage}};
\node[text=white, above right, align=left] (title) at (text.north west) {#3};
\node[fit=(title) (text), line width=0.5mm, rounded corners, draw=#2, inner sep=0pt] (box){};
\begin{scope}[on background layer]
\fill[#2] (title.south west) -- (title.south east) to[out=0, in=180] ([xshift=1.5cm]title.east) -- (title.east-|box.north east) [rounded corners] -- (box.north east) -- (box.north west) [sharp corners] -- cycle;
\end{scope}
\end{tikzpicture}}

\usepackage{pifont}

\begin{document}

\tcbset{sidebyside,
  size=minimal,
  colback=white,
  lower separated=false,
  halign upper=flush center,
  halign lower=flush left,
  lefthand width=2.5cm, 
  frame empty,
}

\sbox0{\mybox[10cm]{green!70!black}{Eat That Frog | Related }{%
\begin{enumerate}
\item ....................................................\hspace*{1cm}..........................

\item ....................................................\hspace*{1cm}..........................

\end{enumerate}
}}%
\sbox1{\mybox[10cm]{blue!70!black}{ Appointments | When | With | Where}{
\begin{enumerate}
\item .....................................  .... : ....        .....................      ..................

\item .....................................  .... : ....        .....................      ..................

\end{enumerate}
}}%

\begin{tabular}{@{}cc@{}}
  \usebox0 & \\
  \usebox1 & \smash{\rotatebox[origin=bl]{90}{% 
  \mybox[\dimexpr \ht0+\ht1+\arraystretch\dp\strutbox-0.666em-0.5mm]% inner xsep=0.333em, linewidth=0.5mm (half in)
    {green!30!black}{Mood}{\centering \dLaughey[2.0] \hfil \dNeutrey[2.0] \hfil \dInnocey[2.0] \hfil \dWalley[2.0]}% 
}} 
\end{tabular} 


\end{document}
  • Thanks @John Kormylo so much. How can vertical align First Box (Eat That Frog) & third box (Mood) ? Please update a bit. Thanks – latexforti Sep 18 '18 at 0:07
  • If you just want to align the rotated box with the top of the first box, you can use \raisebox. If you want to stretch the rotated box to equal the height of the first two boxes, you need to measure them. – John Kormylo Sep 18 '18 at 3:34
  • Thank @John Kormylo. i use this code but don't effort: \smash{\raisebox{\rotatebox[origin=bl]{90}}{% \mybox[3cm]{green!30!black}{Mood}{ \hspace*{0.2cm} \dLaughey[2.0] \hspace*{0.5cm} \dNeutrey[2.0] \hspace*{0.5cm} \\ %\vspace*{1cm} \quad %\vspace{0.2in} \hspace*{0.2cm} \dInnocey[2.0] \hspace*{0.5cm} \dWalley[2.0] \hspace*{0.5cm} }% }} \end{tabular} – latexforti Sep 18 '18 at 6:49
  • The first argument for \raisebox is the distance to move the baseline. Note, the optional arguments of \raisebox make \smash redundant. In any case, you don't need it here. – John Kormylo Sep 18 '18 at 12:15
  • Komylo. How can i set distance between boxes (Mood vs (Appointment/Eat that frog). Thanks – latexforti Sep 18 '18 at 14:47

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.