我有一个很长的图形,需要调整以适应文本高度。当我想在下面添加一些描述时,图形不再居中,并且文本缩进。我试过这个建议使用\floatfoot
,但没有帮助。有什么想法吗?我可以在图形环境中放置一个框吗?
这是 MWE
\documentclass[12pt]{article}
\usepackage{amssymb,amsmath,amsfonts,eurosym,geometry,ulem,graphicx,caption,color,setspace,sectsty,comment,footmisc,caption,pdflscape,subfigure,array,hyperref, bm}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[flushleft]{threeparttable}
\usepackage{amsthm,amsmath}
%\RequirePackage[numbers]{natbib}
%\RequirePackage[authoryear]{natbib}% uncomment this for author-year bibliography
%\RequirePackage{hyperref}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{textcomp}
\usepackage{mathtools}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage[skip=1ex,
font=small,
textfont=it]{caption}
\makeatletter
\newlength{\fnBreite}
\renewcommand{\@makefntext}[1]{%
\settowidth{\fnBreite}{\footnotesize\@thefnmark.i}
\protect\footnotesize\upshape%
\setlength{\@tempdima}{\columnwidth}\addtolength{\@tempdima}{-\fnBreite}%
\makebox[\fnBreite][l]{\@thefnmark.\phantom{}}%
\parbox[t]{\@tempdima}{\everypar{\hspace*{1em}}\hspace*{-1em}\upshape#1}}
\makeatother
\normalem
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{proposition}{Proposition}
\newtheorem{hyp}{Hypothesis}
\newtheorem{subhyp}{Hypothesis}[hyp]
\renewcommand{\thesubhyp}{\thehyp\alph{subhyp}}
\newcommand{\red}[1]{{\color{red} #1}}
\newcommand{\blue}[1]{{\color{blue} #1}}
\usepackage[backend=biber, style=authoryear]{biblatex}
\makeatletter
\newrobustcmd*{\parentexttrack}[1]{%
\begingroup
\blx@blxinit
\blx@setsfcodes
\blx@bibopenparen#1\blx@bibcloseparen
\endgroup}
\AtEveryCite{%
\let\parentext=\parentexttrack%
\let\bibopenparen=\bibopenbracket%
\let\bibcloseparen=\bibclosebracket}
\makeatother
\addbibresource{bib.bib}
\begin{document}
\begin{figure}[hp]
\centering
\captionsetup{font=small,labelfont=small}
\caption{\textit{Title}}\label{fig:lpoly}
\includegraphics[width=\textwidth, height=0.9\textheight, keepaspectratio]{fig1.png}
\medskip
\floatfoot{\scriptsize{Sources: \lipsum[1] \lipsum[1]}}
\end{figure}
\end{document}
这是图片
答案1
- 不清楚你的问题是什么。
- 将标题设置移至文档前言后,将代码片段插入某个 MWE(最小工作示例)(一个小但完整的文档)中,得到以下结果:
(红线表示文档的页面布局)
- 如你所见,结果看起来不错
- 上图生成的 MWE 是:
\documentclass{article}
\usepackage[skip=1ex,
font=small,
textfont=it]{caption}
\usepackage{graphicx}
%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}% For dummy text. Don't use in a real document
\begin{document}
\begin{figure}[hp]
% \centering
\caption{Fig title}
\label{fig:one}
\includegraphics[width=\textwidth, height=0.8\textheight]{example-image-a}%, keepaspectratio
\medskip
\scriptsize
Sources: So here I will also want to put a lot of description even though the figure is already fitted to page size. \lipsum[1]
\end{figure}
\end{document}
\medskip command in
观察图形浮动环境前的空行!- 为了帮助您,您需要提供能够重现您的问题的 MWE。
编辑: 考虑到您在编辑问题后清理所有重复项并根据用途对加载包进行分组后的文档序言,并考虑到我使用的示例图像的原始 MWE 正文,我仍然无法重现您的问题。清理后的文档序言如下(可以):
\documentclass[12pt]{article}
\usepackage{geometry}
%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}% For dummy text. Don't use in a real document
% fonts, encoding, babel
\usepackage[T1]{fontenc}
\usepackage{eurosym, textcomp}
\usepackage[american]{babel}
% math
\usepackage{amssymb, bm, mathtools} % amssymb contain amsfonts
% mathtools contain amsmath
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{proposition}{Proposition}
\newtheorem{hyp}{Hypothesis}
\newtheorem{subhyp}{Hypothesis}[hyp]
\renewcommand{\thesubhyp}{\thehyp\alph{subhyp}}
% tables
\usepackage{array, booktabs, tabularx}
\usepackage[flushleft]{threeparttable}
% figures and captions
\usepackage[export]{adjustbox} % also load graphicx
\usepackage{subfig} % subfigure is obsolete
\usepackage[skip=1ex,
font=small,
textfont=it]{caption}
\usepackage{xcolor}
\newcommand{\red}[1]{{\color{red} #1}}
\newcommand{\blue}[1]{{\color{blue} #1}}
% formattings
\usepackage{csquotes, comment, footmisc}
\usepackage{setspace}
\usepackage{sectsty}
\usepackage{pdflscape}
\makeatletter
\newlength{\fnBreite}
\renewcommand{\@makefntext}[1]{%
\settowidth{\fnBreite}{\footnotesize\@thefnmark.i}
\protect\footnotesize\upshape%
\setlength{\@tempdima}{\columnwidth}\addtolength{\@tempdima}{-\fnBreite}%
\makebox[\fnBreite][l]{\@thefnmark.\phantom{}}%
\parbox[t]{\@tempdima}{\everypar{\hspace*{1em}}\hspace*{-1em}\upshape#1}}
\makeatother
\usepackage{ulem}
\normalem
% bibliography
\usepackage[backend=biber, style=authoryear]{biblatex}
\makeatletter
\newrobustcmd*{\parentexttrack}[1]{%
\begingroup
\blx@blxinit
\blx@setsfcodes
\blx@bibopenparen#1\blx@bibcloseparen
\endgroup}
\AtEveryCite{%
\let\parentext=\parentexttrack%
\let\bibopenparen=\bibopenbracket%
\let\bibcloseparen=\bibclosebracket}
\makeatother
\addbibresource{bib.bib} % so far unknow
\usepackage{hyperref} % had to be loaded last
% except in rare exception (as is cleveref)
% which seems not to be present in your document
\begin{document}
使用它代替上面 MWE 中的前言可以得到与原始答案中显示的相同的结果。
由于我不知道您的原始图像,因此我无法使用它来测试我的 MWE。因此,可能会发生右侧有较大的空白,从而将图像的可见部分移动到图形浮动环境的左边界的情况。您可以使用以下封闭图像来检查这一点fbox
:
\fbox{
\includegraphics[width=\textwidth, height=0.8\textheight]{example-image-a}
}
并查看框架是否与图像绑定。如果没有,则需要使用某些工具剪切空白或借助某些 LaTeX 包(˙tikz˙、pgfplots
ps trick` 等)重新绘制图像。