\documentclass{article}
\usepackage{amsmath,amssymb,graphicx}
\usepackage[a4paper,margin=.8cm]{geometry}
\begin{document}
\title{Plotting Graphs of Functions}
\author{}
\date{\today}
\maketitle
\begin{minipage}{0.45\textwidth}\centering
\(y=x+2\)
\par\bigskip\includegraphics[width=0.9\textwidth]{55}
\end{minipage}
\begin{minipage}{0.45\textwidth}\centering
\(y=x+1\)
\par\bigskip\includegraphics[width=0.9\textwidth]{55}
\end{minipage}\bigskip\bigskip\par
\begin{minipage}{0.45\textwidth}\centering
\(y=x-2\)
\par\bigskip\includegraphics[width=0.9\textwidth]{55}
\end{minipage}
\begin{minipage}{0.45\textwidth}\centering
\(y=2x-2\)
\par\bigskip\includegraphics[width=0.9\textwidth]{55}
\end{minipage}\bigskip\bigskip\par
\clearpage
\begin{minipage}{0.45\textwidth}\centering
\(y=2x+1\)
\par\bigskip\includegraphics[width=0.9\textwidth]{55}
\end{minipage}
\begin{minipage}{0.45\textwidth}\centering
\(y=2x\)
\par\bigskip\includegraphics[width=0.9\textwidth]{55}
\end{minipage}\bigskip\bigskip\par
\begin{minipage}{0.45\textwidth}\centering
\(y=3x-3\)
\par\bigskip\includegraphics[width=0.9\textwidth]{55}
\end{minipage}
\begin{minipage}{0.45\textwidth}\centering
\(y=3x+2\)
\par\bigskip\includegraphics[width=0.9\textwidth]{55}
\end{minipage}\bigskip\bigskip\par
\begin{minipage}{0.45\textwidth}\centering
\(y=-x+2\)
\par\bigskip\includegraphics[width=0.9\textwidth]{55}
\end{minipage}
\begin{minipage}{0.45\textwidth}\centering
\(y=-x-3\)
\par\bigskip\includegraphics[width=0.9\textwidth]{55}
\end{minipage}
\end{document}
以上是我的工作示例。我喜欢结果,但不喜欢代码。
如您所见,我手动对齐了垂直空间(\par\bigskip
)和水平空间(minipage
)。并且每两个单元格(一个单元格是方程式和网格图像)后,我应该添加\par
。
如果我添加更多方程式,例如\(y=2x+3\)
,我别无选择,只能重新排列整个代码。有什么方法可以改进我的代码吗?我已经读过了将图像插入表格环境。但是,我有文本和图像,而不是图像。
答案1
您可以使用tabular
环境。即使您在单元格之间添加更多方程式,它也应该可以工作。
\documentclass{article}
\usepackage{array}
\usepackage{amsmath,amssymb}
\usepackage[demo]{graphicx}
\usepackage[a4paper,margin=.8cm]{geometry}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\begin{document}
\title{Plotting Graphs of Functions}
\author{}
\date{\today}
\maketitle
{\setlength{\tabcolsep}{6pt}%
\renewcommand{\arraystretch}{2}%
\begin{tabular}{@{}*{2}{C{0.45\textwidth}}@{}}
\(y=x+2\) & \(y=x+1\) \\
\includegraphics[width=0.9\linewidth]{55} & \includegraphics[width=0.9\linewidth]{55}\\
\(y=x-2\) & \(y=2x-2\)\\
\includegraphics[width=0.9\linewidth]{55} & \includegraphics[width=0.9\linewidth]{55}\\
\end{tabular}%
\clearpage
\begin{tabular}{@{}*{2}{C{0.45\textwidth}}@{}}
\(y=2x+1\) & \(y=2x\) \\
\includegraphics[width=0.9\linewidth]{55} & \includegraphics[width=0.9\linewidth]{55}\\
\(y=3x-3\) & \(y=3x+2\)\\
\includegraphics[width=0.9\linewidth]{55} & \includegraphics[width=0.9\linewidth]{55}\\
\(y=-x+2\) & \(y=-x-3\)\\
\includegraphics[width=0.9\linewidth]{55} & \includegraphics[width=0.9\linewidth]{55}\\
\end{tabular}%
}
\end{document}
第一页:
第二页: