有人可以让这个家庭作业问题看起来好看点吗
这是我的代码
\documentclass[12pt]{article}
\usepackage[pass]{geometry}% just to show the page margins
\usepackage{tikz}
\usepackage[demo]{graphicx}% remove demo option in actual document
\usetikzlibrary{intersections}
\usepackage{siunitx}
\begin{document}
\begin{description}
\item[Problem 1 : ]
\end{description}
\noindent\begin{minipage}{0.3\textwidth}% adapt widths of minipages to your needs
\begin{tikzpicture}
\draw (-0.5,5) -- (0,5) -- (0,0) -- (5,0) -- (5,5) -- (5.5,5);
\draw[name path=A] (0,0)coordinate(o) -- (5,4.5)node[pos=0.8,sloped,auto]{\SI{10}{\meter}};
\draw[name path=B] (0,3) -- (5,0)node[pos=0.2,sloped,auto]{\SI{8}{\meter}};
\path[name intersections={of=A and B,by={a}}];
\draw[dashed] (a)node[right=1mm]{M} -- (a|-o)node[pos=0.7,auto]{\SI{3}{\meter}};
\end{tikzpicture}
\end{minipage}%
\hfill%
\begin{minipage}{0.6\textwidth}\raggedleft
Two ladders, one 10 meters long and the other 8 meters [long], have been placed in a trench as indicated in the opposite figure. Their point of intersection, M, is 3 meters from the base of the trench. What is the width of the trench?
\end{minipage}
\end{document}
答案1
最好为问题表使用适当的类。这里我使用了exam
类。
\documentclass[12pt]{exam}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usepackage{siunitx}
\qformat{\bfseries Problem \thequestion: \hfill\null}
\begin{document}
\begin{questions}
\question
\begin{minipage}[t]{0.65\textwidth}
Two ladders, one 10 meters long and the other 8 meters [long], have been placed in a trench as indicated in the opposite figure. Their point of intersection, M, is 3 meters from the base of the trench. What is the width of the trench?
\end{minipage}
\hfill
\begin{minipage}[t]{0.25\textwidth}% adapt widths of minipages to your needs
\centering
\begin{tikzpicture}[baseline={(0,2.5)},x=0.6cm,y=0.6cm,font=\footnotesize]
\draw (-0.5,5) -- (0,5) -- (0,0) -- (5,0) -- (5,5) -- (5.5,5);
\draw[name path=A] (0,0)coordinate(o) -- (5,4.5)node[pos=0.9,sloped,auto]{\SI{10}{\meter}};
\draw[name path=B] (0,3) -- (5,0)node[pos=0.05,sloped,auto]{\SI{8}{\meter}};
\path[name intersections={of=A and B,by={a}}];
\draw[dashed] (a)node[right=1mm]{M} -- (a|-o)node[pos=0.7,auto]{\SI{3}{\meter}};
\end{tikzpicture}
\end{minipage}%
\end{questions}
\end{document}
如果没有exam
类,你可以这样做:
\documentclass[12pt]{article}
\usepackage[pass]{geometry}% just to show the page margins
\usepackage{tikz}
%\usepackage[demo]{graphicx}% remove demo option in actual document
\usetikzlibrary{intersections}
\usepackage{siunitx}
\begin{document}
%\section*{Problem 1 :} %% or subsection
\noindent\textbf{Problem 1:}
\begin{minipage}{0.6\linewidth}
Two ladders, one 10 meters long and the other 8 meters [long], have been placed in a trench as indicated in the opposite figure. Their point of intersection, M, is 3 meters from the base of the trench. What is the width of the trench?
\end{minipage}%
\hfill
\begin{minipage}{0.25\linewidth}% adapt widths of minipages to your needs
\begin{tikzpicture}[baseline={(0,2.5)},x=0.55cm,y=0.55cm,font=\footnotesize]
\draw (-0.5,5) -- (0,5) -- (0,0) -- (5,0) -- (5,5) -- (5.5,5);
\draw[name path=A] (0,0)coordinate(o) -- (5,4.5)node[pos=0.8,sloped,auto]{\SI{10}{\meter}};
\draw[name path=B] (0,3) -- (5,0)node[pos=0.1,sloped,auto]{\SI{8}{\meter}};
\path[name intersections={of=A and B,by={a}}];
\draw[dashed] (a)node[right=1mm]{M} -- (a|-o)node[pos=0.7,auto]{\SI{3}{\meter}};
\end{tikzpicture}
\end{minipage}%
\end{document}
答案2
这是否更好?
\documentclass[12pt]{article}
\usepackage[pass,showframe]{geometry}% just to show the page margins
\usepackage{tikz}
\usepackage{graphicx}
\usetikzlibrary{intersections}
\usepackage{siunitx}
\begin{document}
\begin{description}
\item[Problem 1 : ]
\end{description}
\begin{minipage}[t]{0.5\textwidth}
Two ladders, one 10 meters long and the other 8 meters [long], have been placed in a trench as indicated in the opposite figure. Their point of intersection, M, is 3 meters from the base of the trench. What is the width of the trench?
\end{minipage}
\hfill
\noindent\begin{minipage}[t]{0.45\textwidth}% adapt widths of minipages to your needs
\begin{tikzpicture}[baseline={(0,4.5)}]
\draw (-0.5,5) -- (0,5) -- (0,0) -- (5,0) -- (5,5) -- (5.5,5);
\draw[name path=A] (0,0)coordinate(o) -- (5,4.5)node[pos=0.8,sloped,auto]{\SI{10}{\meter}};
\draw[name path=B] (0,3) -- (5,0)node[pos=0.2,sloped,auto]{\SI{8}{\meter}};
\path[name intersections={of=A and B,by={a}}];
\draw[dashed] (a)node[right=1mm]{M} -- (a|-o)node[pos=0.7,auto]{\SI{3}{\meter}};
\end{tikzpicture}
\end{minipage}%
\end{document}