我正在做一个物理问题解决方案库(合集)的项目。我计划每个问题都有一个解决方案放在一个框(mdframed)中。但我想使用 minipage 来压缩空间使用,使其具有多列。这是我想要的屏幕截图。请注意,这是使用图像编辑器编辑的。我使用图像编辑器制作了这个框。有人能帮我用 latex 实现这个吗?
我正在使用我的 WME 代码。但发生了这样的错误
\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}
答案1
这展示了一种带有tcolorbox
和multicol
包的替代解决方案。
\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}
答案2
这里对您的代码和multicol
包进行了一些调整,对于图片,对节点进行了一些修改
\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}