我想创建一个主要为检查清单的文档,但我希望在页面左侧显示图像,在页面右侧显示检查清单。如下图所示:
我的问题是,在 LaTeX 中如何做到这一点,我已经阅读了一些关于multicols
包的讨论,但它不支持浮动图像。
问题:现在,我稍微修改一下您的代码来创建一个横向页面:
\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{array}
\newcounter{rowno}
\setcounter{rowno}{0}
\begin{document}
\noindent
{\begin{minipage}[t]{.5\textwidth} %minipage's width
\raisebox{-.94\textheight}{%
\includegraphics[width=.95\linewidth,height=\textheight]{example-image}
}
\end{minipage}%
\begin{tabular}{@{\hspace{1em}\stepcounter{rowno}\therowno.\hspace{.5em}}p{.45\textwidth}c@{}}
\multicolumn{2}{c}{\large\bfseries Check list}\\[.5em]
This is first item to be checked & $\square$\\
This is second item to be checked and this sentence is going to the second line & $\square$\\
This is third item to be checked and this sentence is going to the second line & $\square$\\
This is fourth item to be checked and this sentence is going to the second line & $\square$\\
This is fifth item to be checked and this sentence is going to the second line & $\square$\\
This is sixth item to be checked and this sentence is going to the second line & $\square$
\end{tabular}
\end{document}
但是我看到生成的 pdf 有两页,第一页是空的,我不确定为什么?
另一个问题 1: 这个线@{\hspace{1em}\stepcounter{rowno}\therowno.\hspace{.5em}}p{.45\textwidth}c@{}
是干什么用的,不知道,我猜这个是用来把表格和 对齐的minipage
,但不知道为什么。
另一个问题2:为什么要使用\raisebox{-.94\textheight}
,如果我删除它,我看到图像仍然可以显示在那里,但清单项将转到图像的右下方。
编辑:添加了两张图片(删除包含命令的行之前和之后raisebox
)
答案1
\documentclass{article}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{array}
\newcounter{rowno}
\setcounter{rowno}{0}
\begin{document}
\noindent
\begin{minipage}[t]{.3\textwidth}
\raisebox{-.94\textheight}{%
\includegraphics[width=.95\linewidth,height=\textheight]{example-image}
}
\end{minipage}%
\begin{tabular}{@{\hspace{1em}\stepcounter{rowno}\therowno.\hspace{.5em}}p{.55\textwidth}c@{}}
\multicolumn{2}{c}{\large\bfseries Check list}\\[.5em]
This is first item to be checked & $\square$\\
This is second item to be checked and this sentence is going to the second line & $\square$
\end{tabular}
\clearpage %% second page
\noindent
\begin{minipage}[t]{.3\textwidth}
\raisebox{-.94\textheight}{%
\includegraphics[width=.95\linewidth,height=\textheight]{example-image}
}
\end{minipage}%
\begin{tabular}{@{\hspace{1em}\stepcounter{rowno}\therowno.\hspace{.5em}}p{.55\textwidth}c@{}}
\multicolumn{2}{c}{\large\bfseries Check list}\\[.5em]
This is first item to be checked & $\square$\\
This is second item to be checked and this sentence is going to the second line & $\square$
\end{tabular}
\end{document}
更新以回答已编辑的问题:
但是我看到生成的 pdf 有两页,第一页是空的,我不确定为什么?
这是因为你把图片放得太低了。你必须调整尺寸
\raisebox{-.82\textheight}{% %% look out the changes
另外,在这里使用也是合适的scale
。请明智地使用这些选项\includegraphics
。
行 @{\hspace{1em}\stepcounter{rowno}\therowno.\hspace{.5em}}p{.45\textwidth}c@{} 是做什么用的,我不知道,我猜这是用来将表格与小页面对齐的,但我不知道为什么。
我尝试将数字放在这里。这两个\hspace
命令使数字远离图片和文本。我使用了p
列类型,因此文本在行末换行。最后一个命令@{}
删除了tabcolsep
最后一列之后的(两列之间的间隙)。
为什么使用 \raisebox{-.94\textheight},如果我删除它,我看到图像仍然可以显示在那里,但检查清单项将进入图像的右下方。
你答对了。它用于将列表项对齐到所需图片的顶部。
希望现在一切都明朗了。祝 TeXing 愉快。:-)
修正后的新 MWE:
\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{array}
\newcounter{rowno}
\setcounter{rowno}{0}
\begin{document}
\noindent
{\begin{minipage}[t]{.5\textwidth} %minipage's width
\raisebox{-.82\textheight}{%
\includegraphics[width=.95\linewidth,height=\textheight]{example-image}
}
\end{minipage}%
\begin{tabular}{@{\hspace{1em}\stepcounter{rowno}\therowno.\hspace{.5em}}p{.5\textheight}c@{}}
\multicolumn{2}{c}{\large\bfseries Check list}\\[.5em]
This is first item to be checked & $\square$\\
This is second item to be checked and this sentence is going to the second line & $\square$\\
This is third item to be checked and this sentence is going to the second line & $\square$\\
This is fourth item to be checked and this sentence is going to the second line & $\square$\\
This is fifth item to be checked and this sentence is going to the second line & $\square$\\
This is sixth item to be checked and this sentence is going to the second line & $\square$
\end{tabular}
\end{document}
请调整尺寸
\begin{minipage}[t]{.4\textwidth}
和
\raisebox{-.94\textwidth}{%
和
p{.8\textheight}
直到你得到令你快乐的东西。