我试图用 LaTex 写一篇文章,并尝试加入以下图像:
我写了以下代码 - 您可以忽略代码中的文本内容,这脱离了上下文,但它显示了我打算让图像出现的位置。在这种情况下,在“下图”和“例如”之间
To illustrate this, let us consider the diagram representation of the 4 x 4 determinant tic tac toe matrix.
Using this diagram below, we can see how Player 0 should mirror it - should player 1 play in a spot player 0 should then play in the grid square with the corresponding letter, as per the diagram below.
\vspace{5mm} %5mm vertical space
\begin{figure}
\centering
\includegraphics[width=80mm,scale=0.9]{/Users/redacted/Downloads/######2.png}
\caption{The progression of the round where Player 1 starts.}
\end{figure}
For example, should Player 1 go first and play, without loss of generality, in $a_{2, 2}$, then Player 0 should play in $a_{2, 1}$, and if Player 0 is to go first, then they can play in any square, then follow this strategy.
\vspace{5mm} %5mm vertical space
The reason that this yields a winning strategy is that one of the properties of the determinant of a matrix is:
不幸的是,当我运行此代码时(我在 Mac 上使用 Atom LaTex 编译器),图像出现在代码的最后一句话之后(矩阵行列式的属性是:) - 事实上,在下一页!(图像上说明)。
有人知道为什么会发生这种情况吗?如果知道,我该如何解决?
编辑:我对这篇文章的序言是:
\documentclass{article}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[margin=1.25in]{geometry}
\usepackage[shortlabels]{enumitem}
\usepackage{graphicx}
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{1pt}
\fancyhfoffset{0.2cm}
\pagestyle{fancy}
\rfoot{Redacted}
\addtolength{\footskip}{0.2in}
\newtheorem*{theorem}{\sc{Theorem}}
\newtheorem*{definition}{\sc{Definition}}
\newtheorem*{proposition}{\sc{Proposition}}
\newtheorem*{corollary}{\sc{Corollary}}
\newtheorem*{claim}{\sc{Claim}}
\newtheorem*{properties}{\sc{Properties}}
\newtheorem*{remark}{\sc{Remark}}
\DeclareMathOperator{\N}{\mathbb{N}}
\DeclareMathOperator{\Z}{\mathbb{Z}}
\DeclareMathOperator{\Q}{\mathbb{Q}}
\DeclareMathOperator{\R}{\mathbb{R}}
\DeclareMathOperator{\C}{\mathbb{C}}
\begin{document}
以下是错误日志:
! Undefined control sequence.
<recently read> \includegraphics
l.82 \includegraphics
[width=\linewidth]{####.png}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Missing number, treated as zero.
<to be read again>
]
l.82 \includegraphics[width=\linewidth]
{####.png}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Illegal unit of measure (pt inserted).
<to be read again>
]
l.82 \includegraphics[width=\linewidth]
{####.png}
Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!
I'll assume that you meant to say pt, for printer's points.
To recover gracefully from this error, it's best to
delete the erroneous units; e.g., type `2' to delete
two letters. (See Chapter 27 of The TeXbook.)
! You can't use `macro parameter character #' in horizontal mode.
l.82 \includegraphics[width=\linewidth]{#
###.png}
Sorry, but I'm not programmed to handle this case;
I'll just pretend that you didn't ask for it.
If you're in the wrong mode, you might be able to
return to the right one by typing `I}' or `I$' or `I\par'.
! You can't use `macro parameter character #' in horizontal mode.
l.82 \includegraphics[width=\linewidth]{##
##.png}
Sorry, but I'm not programmed to handle this case;
I'll just pretend that you didn't ask for it.
If you're in the wrong mode, you might be able to
return to the right one by typing `I}' or `I$' or `I\par'.
! You can't use `macro parameter character #' in horizontal mode.
l.82 \includegraphics[width=\linewidth]{###
#.png}
Sorry, but I'm not programmed to handle this case;
I'll just pretend that you didn't ask for it.
If you're in the wrong mode, you might be able to
return to the right one by typing `I}' or `I$' or `I\par'.
! You can't use `macro parameter character #' in horizontal mode.
l.82 \includegraphics[width=\linewidth]{####
.png}
Sorry, but I'm not programmed to handle this case;
I'll just pretend that you didn't ask for it.
If you're in the wrong mode, you might be able to
return to the right one by typing `I}' or `I$' or `I\par'.
! LaTeX Error: \begin{figure} on input line 81 ended by \end{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.92 \end{document}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
(./Latex - Template.aux)
! You can't use `\end' in internal vertical mode.
\enddocument ... \endgroup \deadcycles \z@ \@@end
l.92 \end{document}
Sorry, but I'm not programmed to handle this case;
I'll just pretend that you didn't ask for it.
If you're in the wrong mode, you might be able to
return to the right one by typing `I}' or `I$' or `I\par'.
! LaTeX Error: \begin{figure} on input line 81 ended by \end{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.92 \end{document}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
! Missing } inserted.
<inserted text>
}
l.92 \end{document}
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.
)
! Emergency stop.
<*> "Latex - Template.tex"
*** (job aborted, no legal \end found)
答案1
感谢您发布日志文件的剪辑。似乎出了什么大问题——根据第一条错误消息,\includegraphics
无法识别该指令;如果graphicx
由于某种原因未加载包,就会发生这种情况。
下面显示的演示代码——特别是[h!]
位置说明符——将一般来说将figure
环境放在您想要的位置。我故意使用限定词“通常”:如果当前页面上没有足够的空间来放置figure
(LaTeX 术语中的“浮动”)在该页面上,LaTeX 会将其放置在下一页的顶部——并用下一段文本填充当前页面的剩余空间,无论它是什么。根据您的代码,图表设置为 8 厘米宽——并且大概,至少那么高。尝试将宽度缩小到 5 或 6 厘米?
\documentclass{article}
\usepackage[demo]{graphicx} % omit 'demo' option in real document
\begin{document}
Using this diagram below, we can see how Player 0 should mirror it - should player 1 play in a spot player 0 should then play in the grid square with the corresponding letter, as per the diagram below.
\begin{figure}[h!]
\centering
\includegraphics[width=80mm,scale=0.9]{/Users/redacted/Downloads/somefilename} % no need to specify ".png"
\caption{The progression of the round where Player 1 starts.}
\end{figure}
For example, should Player 1 go first and play, without loss of generality, in $a_{2, 2}$, then Player 0 should play in $a_{2, 1}$, and if Player 0 is to go first, then they can play in any square, then follow this strategy.
\end{document}