我需要严格遵循论文的格式,因为它是大学提供的。文本的边距为 12.5 厘米,图表的边距也是如此。我需要将图表的标签放在其右侧(在论文的“白色”边距上)。
我在下面复制了我的代码。
非常感谢。
\documentclass[10pt,a4paper,openright]{book}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{lipsum}
\usepackage{floatrow}
\usepackage[labelfont=bf]{caption}
\usepackage{setspace}
\captionsetup{font={footnotesize,stretch=1.2}}
\usepackage{eso-pic}
\usepackage{graphicx}
\usepackage{titlesec}
\usepackage[colored]{shadethm}
\usepackage{color, xcolor}
\usepackage{pstricks, colortab}
\usepackage{fancyhdr}
\usepackage{makecell}
\usepackage{url}
\setlength{\topmargin}{-1.2 cm}
\setlength{\oddsidemargin}{0.2 cm}
\setlength{\evensidemargin}{3.2 cm}
\setlength{\textwidth}{12.5 cm}
\setlength{\textheight}{24.5 cm}
\linespread{1.2}\selectfont
\pagestyle{fancy}
\addtolength{\headwidth}{\marginparsep}
\addtolength{\headwidth}{\marginparwidth}
\fancyhf{}
\begin{document}
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
\begin{figure}[h]
\centering
\includegraphics[width=12.5cm]{figure.pdf}
\caption{capture}
\captionsetup{font={small,stretch=1.2}}
\label{fig1}
\end{figure}
\end{document}
\endinput
答案1
我假设你正在使用标签表示 LaTeX 构造标题。以下是您的 MWE 的编辑版本,它使用sidecap
包(通过阅读文档texdoc sidecap
)将标题放在浮点数的侧面。
% labelfigprob.tex SE 530139 label on margin of figure
\documentclass[10pt,a4paper,openright]{book}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{lipsum}
\usepackage{floatrow}
\usepackage[labelfont=bf]{caption}
\usepackage{setspace}
\captionsetup{font={footnotesize,stretch=1.2}}
\usepackage{eso-pic}
\usepackage{graphicx}
\usepackage{titlesec}
\usepackage[colored]{shadethm}
\usepackage{color, xcolor}
\usepackage{pstricks, colortab}
\usepackage{fancyhdr}
\usepackage{makecell}
\usepackage{url}
\setlength{\topmargin}{-1.2 cm}
\setlength{\oddsidemargin}{0.2 cm}
\setlength{\evensidemargin}{3.2 cm}
\setlength{\textwidth}{12.5 cm}
\setlength{\textheight}{24.5 cm}
\linespread{1.2}\selectfont
\pagestyle{fancy}
\addtolength{\headwidth}{\marginparsep}
\addtolength{\headwidth}{\marginparwidth}
\fancyhf{}
\usepackage{sidecap}
\begin{document}
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
%\begin{figure}[h] % sidecap uses SCfigure instead of figure
\begin{SCfigure}[][h]
\centering
%\includegraphics[width=12.5cm]{figure.pdf} % I don't have this
%\includegraphics[width=12.5cm]{example-image-a} % this comes with the graphicx package
\includegraphics[width=6cm]{example-image-a} % reduce width of figure if necessary to provide more space for the side caption
\caption{capture}
\captionsetup{font={small,stretch=1.2}}
\label{fig1}
%\end{figure}
\end{SCfigure}
\end{document}
用另一种解决方案进行编辑
我尝试过各种sidecap
解决方案,但对于您所需的页面布局,标题总是尽可能小(我认为侧面标题应该在文本宽度内,在您的情况下由图形填充)。
该类(和类memoir
的超集)为将标题放置在边距提供了环境,我认为这就是您想要的(阅读文档book
report
article
sidecaption
texdoc memoir
侧边字幕了解详细信息)。
以下是您的 MWE 的编辑版本,使用类memoir
而book
不是使用floatrow
或caption
包,因为memoir
为这些提供了自己的设施。
% labelfigprob2.tex SE 530139 label on margin of figure
\documentclass[10pt,a4paper,openright]{memoir}
\usepackage{comment}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{lipsum}
%\usepackage{floatrow} % not good with memoir (\newfloat already defined)
%\usepackage[labelfont=bf]{caption} % memoir has its own views about captions
\usepackage{setspace}
%\captionsetup{font={footnotesize,stretch=1.2}}
\usepackage{eso-pic}
\usepackage{graphicx}
\usepackage{titlesec}
\usepackage[colored]{shadethm}
\usepackage{color, xcolor}
\usepackage{pstricks, colortab}
\usepackage{fancyhdr}
\usepackage{makecell}
\usepackage{url}
% memoir has its own methodes for page dimensions, but these work OK
\setlength{\topmargin}{-1.2 cm}
\setlength{\oddsidemargin}{0.2 cm}
\setlength{\evensidemargin}{3.2 cm}
\setlength{\textwidth}{12.5 cm}
\setlength{\textheight}{24.5 cm}
\linespread{1.2}\selectfont
\pagestyle{fancy}
\addtolength{\headwidth}{\marginparsep}
\addtolength{\headwidth}{\marginparwidth}
\fancyhf{}
\sidecapmargin{outer} % put the captions in the outer margin
\begin{document}
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
\begin{figure}
\begin{sidecaption}{capture}[fig1]
\centering
\includegraphics[width=12.5cm]{example-image-a}
\end{sidecaption}
\end{figure}
\end{document}
希望这可以帮助。
答案2
对 Peter Wilson 回答的补充 (+1)。如果我正确理解了您的问题,您喜欢在页面边框中添加标题。为此,您需要在wide
环境中包含图像和标题:
\documentclass[10pt,a4paper,openright]{book}
\setlength{\topmargin}{-1.2 cm}
\setlength{\oddsidemargin}{0.2 cm}
\setlength{\evensidemargin}{3.2 cm}
\setlength{\textwidth}{12.5 cm}
\setlength{\textheight}{24.5 cm}
\linespread{1.2}\selectfont
\usepackage{graphicx}
\usepackage{setspace}
\usepackage[labelfont=bf]{caption}
\captionsetup{font={small,stretch=1.2}}
\usepackage[rightcaption]{sidecap}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
%
\begin{SCfigure}[1][!ht]%
\begin{wide}%
\includegraphics[width=\textwidth]{example-image-duck} % this comes with the graphicx package
\caption{capture}
\label{fig1}
\end{wide}
\end{SCfigure}
%
\lipsum[2]
\end{document}
(红线表示页面布局)
附录: 现在你似乎喜欢在外边距上添加标题。在这种情况下,替换上面的 MWE
\usepackage[rightcaption]{sidecap}
和
\usepackage[outercaption]{sidecap}
经过两次编译后将得到:
上面的图像由以下生成:
\documentclass[10pt,a4paper,openright]{book}
\setlength{\topmargin}{-1.2 cm}
\setlength{\oddsidemargin}{0.2 cm}
\setlength{\evensidemargin}{3.2 cm}
\setlength{\textwidth}{12.5 cm}
\setlength{\textheight}{24.5 cm}
\linespread{1.2}\selectfont
\usepackage{graphicx}
\usepackage{setspace}
\usepackage[labelfont=bf]{caption}
\captionsetup{font={small,stretch=1.2}}
\usepackage[outercaption]{sidecap} % <---
% vertical position of caption
%\sidecaptionvpos{figure}{t} % at the top of image
%\sidecaptionvpos{figure}{c} % vertical centered
\usepackage{lipsum}
\begin{document}
\lipsum[1-3]
%
\begin{SCfigure}[1][!hb]%
\begin{wide}%
\includegraphics[width=\textwidth]{example-image-duck} % this comes with the graphicx package
\caption{capture}
\label{fig1}
\end{wide}
\end{SCfigure}
%
\lipsum[3]
\begin{SCfigure}[1][!ht]%
\begin{wide}%
\includegraphics[width=\textwidth]{example-image-duck} % this comes with the graphicx package
\caption{capture}
\label{fig1}
\end{wide}
\end{SCfigure}
\lipsum[4-5]
\end{document}