使用 svmono 类时,如何才能将图形垂直居中?我在论坛中找到的传统解决方案似乎不适用于此类。请注意,这不是为了实际提交给出版商,而是为了私人用途。
谢谢并问候,豪尔赫。
PS svmono 课程可以下载这里。
示例(已更新):
\documentclass[graybox,envcountchap,vecarrow,twoside]{svmono}
\usepackage[paperheight=240mm,paperwidth=170mm,top=2.5cm,inner=2.5cm]{geometry}
\usepackage[caption=false,font=footnotesize]{subfig}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{floatrow}
\begin{document}
% Some text
\lipsum[1-5]
% A figure in an new page
\clearpage
\begin{figure}[p] %doesn't work
%\begin{figure}[H] %doesn't work
\centering
\sidesubfloat[]{\includegraphics[height=6cm,width=8cm]{example-image-a}}
\vspace{1cm}
\sidesubfloat[]{\includegraphics[height=6cm,width=8cm]{example-image-b}}
\caption{This figure should be centered vertically}
\end{figure}
% Some text in an new page
\clearpage
\lipsum[6-10]
\end{document}
答案1
这是一种不使用figure
环境而是caption
使用包的方法:
\documentclass[graybox,envcountchap,vecarrow,twoside]{article}
\usepackage[paperheight=240mm,paperwidth=170mm,top=2.5cm,inner=2.5cm]{geometry}
\usepackage[caption=false,font=footnotesize]{subfig}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{caption}
%This code makes thhe whole job of vertical centering the image
% #1 includegraphics options
% #2 image name
% #3 image caption
\newsavebox{\mysavebox}
\newlength{\myvspace}
\newcommand\addCenteredImage[3][]{%
\clearpage
\savebox\mysavebox{\vbox{\phantom{.}\par\includegraphics[#1]{#2}}}%
\setlength\myvspace{\dimexpr(\paperheight-\dimexpr(\ht\mysavebox+\dp\mysavebox))/4\relax}%
\phantom{.}\vspace{\myvspace}\par\usebox\mysavebox\captionof{figure}{#3}\clearpage%
}
\begin{document}
% Some text
\lipsum[1-5]
% A figure in an new page
\addCenteredImage[height=10cm,width=10cm]{example-image-a}{This figure should be centered vertically}
\lipsum[6-10]
\end{document}
据我所知,这是一种使用简单命令的方法。
输出是您所期望的图像。
编辑子图:(在 OP 编辑之后)
\documentclass[graybox,envcountchap,vecarrow,twoside]{article}
\usepackage[paperheight=240mm,paperwidth=170mm,top=2.5cm,inner=2.5cm]{geometry}
\usepackage[caption=false,font=footnotesize]{subfig}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{caption}
%This code makes thhe whole job of vertical centering the image
% #1 includegraphics options
% #2 image name
% #3 image caption
\newsavebox{\mysavebox}
\newlength{\myvspace}
\newcommand\addCenteredImage[1]{%
\clearpage
\savebox\mysavebox{\vbox{\phantom{.}\par #1}}%
\setlength\myvspace{\dimexpr(\paperheight-\dimexpr(\ht\mysavebox+\dp\mysavebox))/4\relax}%
\phantom{.}\vspace{\myvspace}\par\usebox\mysavebox\clearpage%
}
\begin{document}
% Some text
\lipsum[1-5]
% A figure in an new page
\addCenteredImage{%
\centering
\includegraphics[height=3cm,width=8cm]{example-image-a}
\captionof{subfigure}{Test 1}
\vspace{1cm}
\includegraphics[height=3cm,width=8cm]{example-image-b}
\captionof{subfigure}{Test 2}
\captionof{figure}{This figure should be centered vertically}
}
\lipsum[6-10]
\end{document}
输出:
答案2
页面浮动使用以下方式排版
\vspace*{\@fptop}
<material of the float>
\vspace*{\@fpbot}
该类svmono
设置\@fptop
为零,保留\@fpbot
默认值0pt plus 1fil
。
只需添加适当的设置。
\documentclass[graybox,envcountchap,vecarrow,twoside]{svmono}
\usepackage[paperheight=240mm,paperwidth=170mm,top=2.5cm,inner=2.5cm]{geometry}
\usepackage[caption=false,font=footnotesize]{subfig}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{floatrow}
\makeatletter
\setlength\@fptop{0pt plus 1fil} % <--- restore the values
\makeatother
\begin{document}
% Some text
\lipsum[1-5]
% A figure in an new page
\clearpage
\begin{figure}[p] %doesn't work
%\begin{figure}[H] %doesn't work
\centering
\sidesubfloat[]{\includegraphics[height=6cm,width=8cm]{example-image-a}}
\vspace{1cm}
\sidesubfloat[]{\includegraphics[height=6cm,width=8cm]{example-image-b}}
\caption{This figure should be centered vertically}
\end{figure}
% Some text in an new page
\clearpage
\lipsum[6-10]
\end{document}
答案3
感谢大家的善意建议。Sigur 提出的解决方案很管用(见下文)。问候,Jorge。
\documentclass[graybox,envcountchap,vecarrow,twoside]{svmono}
\usepackage[paperheight=240mm,paperwidth=170mm,top=2.5cm,inner=2.5cm]{geometry}
\usepackage[caption=false,font=footnotesize]{subfig}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{floatrow}
\begin{document}
% Some text
\lipsum[1-5]
% A figure in an new page
\clearpage\null\vfil
\begin{figure}[h]
\centering
\sidesubfloat[]{\includegraphics[height=6cm,width=8cm]{example-image-a}}
\vspace{1cm}
\sidesubfloat[]{\includegraphics[height=6cm,width=8cm]{example-image-b}}
\caption{This figure should be centered vertically}
\end{figure}
% Some text in an new page
\clearpage
\lipsum[6-10]
\end{document}