LaTeX中强制固定图片位置且不改变原有排版格式的实现问询
解决方法
你遇到的问题核心是figure为LaTeX默认浮动体环境,自带位置自动调整逻辑,即便添加[h]参数也仅为「优先放置在当前位置」,无法做到强制固定,再加上你将浮动体插入到了完整句子中间,才会出现图文顺序颠倒的问题。
你可以用caption宏包提供的\captionof命令实现非浮动图片插入,完全固定图片位置,不需要使用会改变排版的float宏包,也不会破坏原有文本格式,具体修改如下:
- 导言区新增
\usepackage{caption}导入宏包 - 将原有插入在句子中间的
figure环境拆分到两个分句之间,替换为非浮动写法
修改后完整代码如下:
\documentclass[12pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage{graphicx} \usepackage{amsmath, amsthm, amssymb} \usepackage[a4paper,includeheadfoot,margin=2.54cm]{geometry} \usepackage{caption} % 新增导包 \newtheorem{theorem}{Theorem} \begin{document} \section{The Koch Snowflake} The \emph{Koch snowflake}, one of the first fractals, is based on work by the Swedish mathematician Helge von Koch~\cite{koch}. It is what we get if we start with an equilateral triangle % 替换原有figure环境为非浮动写法,位置完全固定 \begin{center} \includegraphics[width=10cm]{snowflake.jpg} \captionof{figure}{The Koch snowflake after zero, one, two, and three iterations.} \label{koch} \end{center} and repeat the following an infinite number of times: \end{document}
效果说明
该写法完全保留原有排版:上方文本宽度无变化,图片宽度保持你设置的10cm不变,图片下方文本正常左对齐,不会出现格式错乱问题。
内容的提问来源于stack exchange,提问作者tonsih
相关产品推荐
相关产品推荐

