我在将图片插入到我的 latex 文档中的特定位置时遇到了麻烦。目前,我在文本中有两个图形环境,但它们打印在文档的背面,在参考书目之后。我遗漏了什么吗?
这两张图片都应为全页大小,而不是传统的小图形或浮动。在这种情况下,我使用图形环境可能是错误的,但我不确定。
\documentclass[12pt, a4paper, twoside]{article}
\usepackage[margin=1in,bindingoffset=15.5mm,heightrounded]{geometry}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\begin{document}
I have some text here. Then pics.
\newpage
\begin{figure}[ht!]
\centering
\includegraphics[scale=0.75, angle=90, width=\textwidth]{hamlet.jpg}
\caption{cool picture}
\end{figure}
\newpage
\begin{figure}[ht!]
\centering
\includegraphics[scale=0.75, angle=270, width=\textwidth]{kinglear.jpg}
\caption{cool picture 2}
\end{figure}
\newpage
some more text here
\end{document}
答案1
由于图像必须放置在特定位置,因此使用浮动环境并不方便;您可以\captionof
使用capt-of
或者caption
为你的图形添加标题的包:
\documentclass[12pt, a4paper, twoside]{article}
\usepackage[margin=1in,bindingoffset=15.5mm,heightrounded]{geometry}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx}
\usepackage{caption}
\begin{document}
I have some text here. Then pics.
\clearpage
{
\centering
\includegraphics[scale=0.75, angle=90, width=\textwidth]{hamlet.jpg}
\captionof{figure}{cool picture}
\clearpage
\includegraphics[scale=0.75, angle=270, width=\textwidth]{kinglear.jpg}
\captionof{figure}{cool picture 2}
}
\clearpage
some more text here
\end{document}
选项demo
只是graphicx
用黑色矩形替换实际图形;不是在实际文档中使用该选项。
根据您控制图像大小的方式,您还可以使用 包装每个图像及其标题,minipage
以防止出现不必要的分页符;例如
\clearpage
\noindent\begin{minipage}{\textwidth}
\centering
\includegraphics[scale=0.75, angle=90, width=\textwidth]{hamlet.jpg}
\captionof{figure}{cool picture}
\end{minipage}
\clearpage
\noindent\begin{minipage}{\textwidth}
\centering
\includegraphics[scale=0.75, angle=270, width=\textwidth]{kinglear.jpg}
\captionof{figure}{cool picture 2}
\end{minipage}
\clearpage
答案2
使用环境并没有错figure
。既然您提到这些图形应该占据一整页,您可以加载包afterpage
并使用其\afterpage
命令将图形的排版推迟到下一个分页符发生;这将使您不必弄清楚何时发出\newpage
或\clearpage
命令。以下是我要做的:
\documentclass[12pt, a4paper, twoside]{article}
\usepackage[margin=1in,bindingoffset=15.5mm,heightrounded]{geometry}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx} % delete 'demo' option in real document
\usepackage{afterpage}
\begin{document}
I have some text here. Then pics. some more text here
\afterpage{
\clearpage % flush any pending floats
\begin{figure}[p] % use [p], not [ht!]
\centering
\includegraphics[scale=0.75, angle=90, width=\textwidth]{hamlet.jpg}
\caption{cool picture}
\end{figure}
\clearpage
\begin{figure}[p] % use [p], not [ht!]
\centering
\includegraphics[scale=0.75, angle=270, width=\textwidth]{kinglear.jpg}
\caption{cool picture 2}
\end{figure}
\clearpage % force both floats to be typeset
} % end of scope of \afterpage instruction
some more text here
% this may or may not be typeset on the page prior to
% the two floats-only pages, depending on how much
% space was left on the page when \afterpage is
% encountered.
\end{document}