2

I'm at project make a physics problem-solution bank(collection). I'm planning that each a problem, there a solution inside a box (mdframed). But I'd like to make compact space usage, having multicolumn using minipage. This is screenshot that I want. Please notice that this is edited using image editor. I make this box using image editor. Anyone can help me to make this happen using latex?

enter image description here

There are my WME code that I'm working. But such error happen

\documentclass[12pt,legalpaper]{article}
\usepackage[latin1]{inputenc}
\usepackage[indonesian]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{mathpazo}
\renewcommand{\rmdefault}{put}
\usepackage{enumitem}
\usepackage[dvipsnames,svgnames]{xcolor}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{tikz}   
\usepackage{adjustbox}
\usepackage{lipsum}
\usepackage[left=1.5cm,right=1.5cm,top=0.2cm,bottom=1.5cm]{geometry}
\usepackage[framemethod=TikZ]{mdframed}
\newcounter{solusi}[chapter]\setcounter{solusi}{0}
\renewcommand{\thesolusi}{\arabic{chapter}.\arabic{solusi}}
\newenvironment{solusi}[2][]{%
\refstepcounter{solusi}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut Solusi~\thesolusi};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut Solusi~\thesolusi :~#1};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=blue!20,%
linewidth=2pt,topline=true,%
frametitleaboveskip=\dimexpr-\ht\strutbox\relax
}
\begin{mdframed}[]\relax%
\label{#2}}{\end{mdframed}}



\begin{document}
\begin{enumerate}


\item (skor:11) Empat buah vektor $\vec{p}$, $\vec{q}$, $\vec{r}$,dan  $\vec{s}$ mempunyai berada pada koordinat kartesian seperti pada gambar. Apabila $\vec{p}$=10N, $\vec{q}$=5N, $\vec{r}$=3N, dan $\vec{s}$=1N. Tentukan resultan keempat vektor tersebut!


\begin{solusi}  % this is mdframed box from texblog

\adjustbox{valign=t}{\begin{minipage}[t]{0.42\textwidth}
\item (bobot:11) \begin{tikzpicture}[scale=0.3, > = stealth]
\draw[thin, <->, >= latex] (0,8) -- (0,0) -- (11,0);
\draw[thin, <->, >= latex] (-10,0) -- (0,0) -- (0,-8);
\draw[very thick, ->] (0,0) -- (8,6); %a
\draw[thick,blue, ->] (0,0) -- (0,6); %ay
\draw[thick,blue, ->] (0,0) -- (8,0); %ax
\draw[dashed, gray] (0,6) -- (8,6);
\draw[dashed, gray](8,0) -- (8,6);
%------------------------------------
\draw[very thick, ->] (0,0)--(-3,4);
\draw[very thick,red, ->] (0,0) -- (0,4); %by
\draw[very thick,red, ->] (0,0) -- (-3,0); %bx
\draw[dashed, gray] (0,4) -- (-3,4);
\draw[dashed, gray](-3,0) -- (-3,4);

\draw[very thick, ->] (0,0)--(0,-1);
\draw[very thick, ->] (0,0)-- (0,3);

\node at ( 11,0) [right] {$x$};
\node at ( 0,8) [above] {$y$};
\node at ( -10,0) [left] {$-x$};
\node at ( 0,-8) [below] {$-y$};
\node at (1,0) [above right] {\scriptsize $37^\circ$};
\node at (-1,0) [above left] {\scriptsize $53^\circ$};
\node at ( 6,3.5) [above left] {$\vec{p}$\small =10N};
\node at ( -1.5,4) [above left] {$\vec{q}$\small =5N};
\node at ( 0,2) [above] {$\vec{r}$\small =3N};
\node at ( 0,-1) [below right]{$\vec{s}$\small =1N};
\end{tikzpicture}
\end{minipage}}\hfill
%
\adjustbox{valign=t}{\begin{minipage}[t]{0.25\textwidth}
Menentukan komponen-komponen vektor \hfill \break
$p_x = 10.\cos37^\circ =8$ {\color{red}{(score:1)}}\hfill \break
$q_x=-5.\cos53^\circ=-3$  {\color{red}{(score:1)}}\hfill \break
$r_x=0$  {\color{red}{(score:1)}}\hfill \break
$s_x=0$  {\color{red}{(score:1)}}\hfill \break
$R_x=5$N  {\color{red}{(score:1)}} \hfill \break
\hfill \break
$R=\sqrt{R_{x}^2+R_{y}^2}$ \hfill \break
$R=\sqrt{5^2+12^2}$\hfill \break
$R=\sqrt{169}=13N$  {\color{red}{(score:1)}}
%\begin{enumerate}[label=(\alph*)]
%\item Resultan $\vec{p}+\vec{q}+\vec{r}+\vec{s}$ !
%\item Arah resultan $\vec{p}+\vec{q}+\vec{r}$ terhadap sumbu $x$ positif;
%
%\end{enumerate}

\end{minipage}}\hfill
%
\adjustbox{valign=t}{\begin{minipage}[t]{0.25\textwidth}
Menentukan komponen-komponen vektor \hfill \break
$p_y = 10.\cos37^\circ =6$  {\color{red}{(score:1)}} \hfill \break
$q_y=5.\sin53^\circ=4$  {\color{red}{(score:1)}}\hfill \break
$r_y=3$  {\color{red}{(score:1)}}\hfill \break
$s_y=-1$  {\color{red}{(score:1)}}\hfill \break
$R_y=12$N {\color{red}{(score:1)}}\hfill \break
%\begin{enumerate}[label=(\alph*)]
%\item Resultan $\vec{p}+\vec{q}+\vec{r}+\vec{s}$ !
%\item Arah resultan $\vec{p}+\vec{q}+\vec{r}$ terhadap sumbu $x$ positif;
%
%\end{enumerate}
\end{minipage}}\hfill


\end{solusi}

\end{enumerate}
\end{document}

enter image description here

  • sorry, I don't understand your question at all. please be more specific. – naphaneal Sep 9 '16 at 6:49
  • I've add some MWE there. I need make something like that picture. But I've problem when using minipage inside mdframed. Please notice that my picture just using image editor. – arif.stwan Sep 9 '16 at 7:01
  • I think in your case best to use multicol package rather then minipage – Salim Bou Sep 9 '16 at 7:09
  • Is multicol suitable for tikz ? – arif.stwan Sep 9 '16 at 7:14
2

This shows an alternative solution with tcolorbox and multicol packages.

\documentclass{book}
\usepackage[most]{tcolorbox}
\usepackage{lmodern}
\usepackage{multicol}
\usepackage{adjustbox}

\newtcolorbox[auto counter, number within=chapter]{solusi}[2][]
    {colframe=blue!20, 
        colback=white, 
        sharp corners,
        title=Solusi~\thetcbcounter: #2,
        enhanced,
        coltitle=black,
        fonttitle=\bfseries,
        attach boxed title to top left={yshift*=-\tcboxedtitleheight/2, xshift=3mm},
        boxed title style={sharp corners, colback=blue!20},
        #1
        }

\begin{document}

\chapter{First chapter}

\begin{solusi}{Some solution}
\centering
\begin{tikzpicture}[scale=0.3, > = stealth]
\draw[thin, <->, >= latex] (0,8) -- (0,0) -- (11,0);
\draw[thin, <->, >= latex] (-10,0) -- (0,0) -- (0,-8);
\draw[very thick, ->] (0,0) -- (8,6); %a
\draw[thick,blue, ->] (0,0) -- (0,6); %ay
\draw[thick,blue, ->] (0,0) -- (8,0); %ax
\draw[dashed, gray] (0,6) -- (8,6);
\draw[dashed, gray](8,0) -- (8,6);
%------------------------------------
\draw[very thick, ->] (0,0)--(-3,4);
\draw[very thick,red, ->] (0,0) -- (0,4); %by
\draw[very thick,red, ->] (0,0) -- (-3,0); %bx
\draw[dashed, gray] (0,4) -- (-3,4);
\draw[dashed, gray](-3,0) -- (-3,4);

\draw[very thick, ->] (0,0)--(0,-1);
\draw[very thick, ->] (0,0)-- (0,3);

\node at ( 11,0) [right] {$x$};
\node at ( 0,8) [above] {$y$};
\node at ( -10,0) [left] {$-x$};
\node at ( 0,-8) [below] {$-y$};
\node at (1,0) [above right] {\scriptsize $37^\circ$};
\node at (-1,0) [above left] {\scriptsize $53^\circ$};
\node at ( 6,3.5) [above left] {$\vec{p}$\small =10N};
\node at ( -1.5,4) [above left] {$\vec{q}$\small =5N};
\node at ( 0,2) [above] {$\vec{r}$\small =3N};
\node at ( 0,-1) [below right]{$\vec{s}$\small =1N};
\end{tikzpicture}
\tcblower
\begin{multicols}{2}
Menentukan komponen-komponen vektor \hfill \break
$p_x = 10.\cos37^\circ =8$ {\color{red}{(score:1)}}\hfill \break
$q_x=-5.\cos53^\circ=-3$  {\color{red}{(score:1)}}\hfill \break
$r_x=0$  {\color{red}{(score:1)}}\hfill \break
$s_x=0$  {\color{red}{(score:1)}}\hfill \break
$R_x=5$N  {\color{red}{(score:1)}} \hfill \break
\hfill \break
$R=\sqrt{R_{x}^2+R_{y}^2}$ \hfill \break
$R=\sqrt{5^2+12^2}$\hfill \break
$R=\sqrt{169}=13N$  {\color{red}{(score:1)}}
$p_y = 10.\cos37^\circ =6$  {\color{red}{(score:1)}} \hfill \break
$q_y=5.\sin53^\circ=4$  {\color{red}{(score:1)}}\hfill \break
$r_y=3$  {\color{red}{(score:1)}}\hfill \break
$s_y=-1$  {\color{red}{(score:1)}}\hfill \break
$R_y=12$N {\color{red}{(score:1)}}\hfill \break
\end{multicols}
\end{solusi}

\begin{solusi}[sidebyside, lefthand width=3.5cm]{Some solution}
\adjustbox{width=\linewidth}{
\begin{tikzpicture}[scale=0.3, > = stealth]
\draw[thin, <->, >= latex] (0,8) -- (0,0) -- (11,0);
\draw[thin, <->, >= latex] (-10,0) -- (0,0) -- (0,-8);
\draw[very thick, ->] (0,0) -- (8,6); %a
\draw[thick,blue, ->] (0,0) -- (0,6); %ay
\draw[thick,blue, ->] (0,0) -- (8,0); %ax
\draw[dashed, gray] (0,6) -- (8,6);
\draw[dashed, gray](8,0) -- (8,6);
%------------------------------------
\draw[very thick, ->] (0,0)--(-3,4);
\draw[very thick,red, ->] (0,0) -- (0,4); %by
\draw[very thick,red, ->] (0,0) -- (-3,0); %bx
\draw[dashed, gray] (0,4) -- (-3,4);
\draw[dashed, gray](-3,0) -- (-3,4);

\draw[very thick, ->] (0,0)--(0,-1);
\draw[very thick, ->] (0,0)-- (0,3);

\node at ( 11,0) [right] {$x$};
\node at ( 0,8) [above] {$y$};
\node at ( -10,0) [left] {$-x$};
\node at ( 0,-8) [below] {$-y$};
\node at (1,0) [above right] {\scriptsize $37^\circ$};
\node at (-1,0) [above left] {\scriptsize $53^\circ$};
\node at ( 6,3.5) [above left] {$\vec{p}$\small =10N};
\node at ( -1.5,4) [above left] {$\vec{q}$\small =5N};
\node at ( 0,2) [above] {$\vec{r}$\small =3N};
\node at ( 0,-1) [below right]{$\vec{s}$\small =1N};
\end{tikzpicture}}
\tcblower
\begin{multicols}{2}\small
Menentukan komponen-komponen vektor \hfill \break
$p_x = 10.\cos37^\circ =8$ {\color{red}{(score:1)}}\hfill \break
$q_x=-5.\cos53^\circ=-3$  {\color{red}{(score:1)}}\hfill \break
$r_x=0$  {\color{red}{(score:1)}}\hfill \break
$s_x=0$  {\color{red}{(score:1)}}\hfill \break
$R_x=5$N  {\color{red}{(score:1)}} \hfill \break
\hfill \break
$R=\sqrt{R_{x}^2+R_{y}^2}$ \hfill \break
$R=\sqrt{5^2+12^2}$\hfill \break
$R=\sqrt{169}=13N$  {\color{red}{(score:1)}}
$p_y = 10.\cos37^\circ =6$  {\color{red}{(score:1)}} \hfill \break
$q_y=5.\sin53^\circ=4$  {\color{red}{(score:1)}}\hfill \break
$r_y=3$  {\color{red}{(score:1)}}\hfill \break
$s_y=-1$  {\color{red}{(score:1)}}\hfill \break
$R_y=12$N {\color{red}{(score:1)}}\hfill \break
\end{multicols}
\end{solusi}
\end{document}

enter image description here

enter image description here

1

Here some adjustments of your code with multicol package, for the picture there are some modifications for nodes

\documentclass[12pt,legalpaper]{book}
\usepackage[latin1]{inputenc}
\usepackage[indonesian]{babel}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{mathpazo}
\renewcommand{\rmdefault}{put}
\usepackage{enumitem}
\usepackage[dvipsnames,svgnames]{xcolor}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{tikz}   
\usepackage{adjustbox}
\usepackage{lipsum}
\usepackage[left=1.5cm,right=1.5cm,top=0.2cm,bottom=1.5cm]{geometry}
\usepackage[framemethod=TikZ]{mdframed}
\newcounter{solusi}[chapter]\setcounter{solusi}{0}
\renewcommand{\thesolusi}{\arabic{chapter}.\arabic{solusi}}
\newenvironment{solusi}[2][]{%
\refstepcounter{solusi}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut Solusi~\thesolusi};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut Solusi~\thesolusi :~#1};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=blue!20,%
linewidth=2pt,topline=true,%
frametitleaboveskip=\dimexpr-\ht\strutbox\relax
}
\begin{mdframed}[]\relax%
\label{#2}}{\end{mdframed}}

\def\sco{{\color{red}(score:1)}}

\begin{document}
\begin{enumerate}


\item (skor:11) Empat buah vektor $\vec{p}$, $\vec{q}$, $\vec{r}$,dan  $\vec{s}$ mempunyai berada pada koordinat kartesian seperti pada gambar. Apabila $\vec{p}$=10N, $\vec{q}$=5N, $\vec{r}$=3N, dan $\vec{s}$=1N. Tentukan resultan keempat vektor tersebut!


\begin{solusi} {}{} % this is mdframed box from texblog
\begin{multicols}{3}
\begin{tikzpicture}[scale=0.26,>= stealth,every node/.style={font=\small,scale=0.75}]
\draw[thin, <->, >= latex] (0,-8)node[below]{$-y$} -- (0,8)node[above]{$y$};
\draw[thin, <->, >= latex] (-9,0)node[below]{$-x$} -- (10,0)node[below]{$x$};
\draw[very thick, ->] (0,0) -- (8,6)node [above]{$\vec{p}=10N$}; %a
\draw[thick,blue, ->] (0,0) -- (0,6); %ay
\draw[thick,blue, ->] (0,0) -- (8,0); %ax
\draw[dashed, gray] (0,6) -- (8,6);
\draw[dashed, gray](8,0) -- (8,6);
%------------------------------------
\draw[very thick, ->] (0,0)--(-3,4)node [above]{$\vec{q}=5N$};
\draw[very thick,red, ->] (0,0) -- (0,4); %by
\draw[very thick,red, ->] (0,0) -- (-3,0); %bx
\draw[dashed, gray] (0,4) -- (-3,4);
\draw[dashed, gray](-3,0) -- (-3,4);

\draw[very thick, ->] (0,0)--(0,-1)node[right]{$\vec{s}=1N$};
\draw[very thick, ->] (0,0)-- (0,3)node[right]{$\vec{r}=3N$};

\node at (1,0) [above right] {\scriptsize $37^\circ$};
\node at (-1,0) [above left] {\scriptsize $53^\circ$};
\end{tikzpicture}
Menentukan komponen-komponen vektor \\
$p_x = 10.\cos37^\circ =8$ \sco \\
$q_x=-5.\cos53^\circ=-3$  \sco \\
$r_x=0$  \sco \\
$s_x=0$  \sco \\
$R_x=5$N  \sco \\
$R=\sqrt{R_{x}^2+R_{y}^2}$ \\
$R=\sqrt{5^2+12^2}$ \\
$R=\sqrt{169}=13N$  \sco
%\begin{enumerate}[label=(\alph*)]
%\item Resultan $\vec{p}+\vec{q}+\vec{r}+\vec{s}$ !
%\item Arah resultan $\vec{p}+\vec{q}+\vec{r}$ terhadap sumbu $x$ positif;
%
%\end{enumerate}
Menentukan komponen-komponen vektor \\
$p_y = 10.\cos37^\circ =6$  \sco \\
$q_y=5.\sin53^\circ=4$  \sco \\
$r_y=3$  \sco \\
$s_y=-1$ \sco \\
$R_y=12$N \sco
%\begin{enumerate}[label=(\alph*)]
%\item Resultan $\vec{p}+\vec{q}+\vec{r}+\vec{s}$ !
%\item Arah resultan $\vec{p}+\vec{q}+\vec{r}$ terhadap sumbu $x$ positif;
%
%\end{enumerate}
\end{multicols}
\end{solusi}

\end{enumerate}

\end{document} 

enter image description here

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.