%
\documentclass{book} %
%
\usepackage[fleqn]{amsmath} %
\usepackage{amsthm,amssymb} %
\usepackage[explicit]{titlesec} %
\usepackage{titletoc} %
\usepackage[nottoc]{tocbibind}
\usepackage{tikz} % tikz - essential
\usepackage{xcolor,colortbl} % define colors, color table, order important
\usepackage[margin=10pt,font=normalsize,labelfont=bf,labelsep=space,position=below]{caption} % 08_03_2014
\usepackage[position=below,textfont=normal,labelfont=bf]{caption,subfig} % 08_03_2014 (subfig from package)
\usepackage[dvips=true,pdftex=true,verbose]{geometry}
\usepackage{float}
\usepackage{subfloat}
\usepackage[a4,frame,center]{crop} % a4=210mm x 297mm
\usepackage{tikz} % tikz - essential
\usepackage{tcolorbox}
\usepackage{bookmark}
\usepackage{hyperref}
%
\setlength{\unitlength}{1mm} % 1mm=2.834646pt; 1pt=0.3515mm
%
\frontmatter
\definecolor{DarkCream}{rgb}{1.00,1.00,0.85} % FFFFFB
\definecolor{DarkRed}{rgb}{0.45,0.00,0.00} % #880000
\begin{document}
\vspace{6pt}
\noindent The border at the top of the graphic changes according to whether dvi or pdf is chosen.
\noindent It is the pdf that I want to finish - with a uniform border.
\vspace{6pt}
\begin{figure}[htp]
\begin{tikzpicture}[rounded corners,draw=DarkRed,line width=0.7pt,inner sep=2pt,inner ysep=4.8pt]
\node at (0,0) [rectangle,draw,fill=DarkCream]{
\begin{minipage}[t]{119.4mm}
\subfloat[{\fontsize{10}{12}\selectfont{\hspace{0.6pt}Inequality region}}]
{\label{fig:inequalityregion}
\includegraphics[scale=1.0]{../my_book/chap_02_function_figs/fig_06a_inequality_2x-3y_leq_4}} %
\hspace{0.4pt}\subfloat[\hspace{1.2pt}Proof of inequality] %
{\label{fig:inequalityproof}
\hspace{1.0pt}\includegraphics[scale=1.0]{../my_book/chap_02_function_figs/fig_06b_proof_inequality_2x-3y_leq_4}}
\end{minipage}};
\end{tikzpicture}
\caption{\hspace{3.2pt}Region satisfying the inequality}
\label{fig:twodiminequalityregion}
\end{figure}
\end{document}
答案1
正如我在评论中提到的,我无法编译您的代码。所以我在途中重新安排了它,因为我通常处理类似的情况。
- 文档中使用的任何包我只加载一个
- 带有选项的包(如
caption
,,subfig
...)我单独加载
您的图构造非常不寻常,我怀疑它能否编译(好吧,一些评论报告不同)。因此,我重新整理了您的代码,如下所示:
\documentclass{book} %
\usepackage[verbose]{geometry}
\usepackage[a4,frame,center]{crop}
\usepackage[explicit]{titlesec} %
\usepackage{titletoc} %
\usepackage[nottoc]{tocbibind}
\usepackage[fleqn]{amsmath} %
\usepackage{amsthm,amssymb} %
\usepackage[table]{xcolor} % define colors, color table, order important
\definecolor{DarkCream}{rgb}{1.00,1.00,0.85} % FFFFFB
\definecolor{DarkRed}{rgb}{0.45,0.00,0.00} % #880000
\usepackage{tikz} % tikz - essential
\usepackage[margin=10pt,
font=normalsize,
labelfont=bf,
labelsep=space,
position=below]{caption} % 08_03_2014
\usepackage[position=below,
textfont=normal,
labelfont=bf]{subfig} % 08_03_2014 (subfig from package)
%\usepackage{float} % is it really necessary?
%\usepackage{subfloat} % it is not used
\usepackage{tikz} % tikz - essential
\usepackage{graphicx}
\usepackage{tcolorbox}
\usepackage{bookmark}
\usepackage{hyperref}
%
\setlength{\unitlength}{1mm} % 1mm=2.834646pt; 1pt=0.3515mm
%
%\frontmatter 5<--- here it hasnt any function
\tikzset{fig/.style = {
mynode/.style = {shape=rectangle, rounded corners,
draw=DarkRed, line width=0.7pt, fill=DarkCream,
inner sep=2pt, inner ysep=4.8pt, align=center}}}
\begin{document}
The border at the top of the graphic changes according to whether dvi or pdf is chosen.
It is the pdf that I want to finish - with a uniform border.
\begin{figure}[htp]
\subfloat[Inequality region \label{fig:inequalityregion}]
{\tikz[fig]\node[mynode,text width=0.48\hsize] {\includegraphics[width=\hsize]{example-image-a}};
}
\hfill
\subfloat[Proof of inequality \label{fig:inequalityproof}]
{\tikz[fig]\node[mynode,text width=0.48\hsize] {\includegraphics[width=\hsize]{example-image-b}};
}
\caption{\hspace{3.2pt}Region satisfying the inequality}
\label{fig:twodiminequalityregion}
\end{figure}
\end{document}
给出pdflatex
以下图像:
这就是你要找的吗?
编辑: 嗯,上面的解决方案似乎不是你想要的。那么这是这个吗?
为此我使用以下代码:
\documentclass{book} %
\usepackage[verbose]{geometry}
\usepackage[a4,frame,center]{crop}
\usepackage[explicit]{titlesec} %
\usepackage{titletoc} %
\usepackage[nottoc]{tocbibind}
\usepackage[fleqn]{amsmath} %
\usepackage{amsthm,amssymb} %
\usepackage[table]{xcolor} % define colors, color table, order important
\definecolor{DarkCream}{rgb}{1.00,1.00,0.85} % FFFFFB
\definecolor{DarkRed}{rgb}{0.45,0.00,0.00} % #880000
%\usepackage{tikz} % tikz - for this example not really essential
\usepackage[margin=10pt,
font=normalsize,
labelfont=bf,
labelsep=space,
position=below]{caption} % 08_03_2014
\usepackage[position=below,
textfont=normal,
labelfont=bf]{subfig} % 08_03_2014 (subfig from package)
%\usepackage{float} % is it really necessary?
%\usepackage{subfloat} % it is not used
\usepackage{tikz} % tikz - essential
\usepackage{graphicx}
\usepackage{tcolorbox}
\usepackage{bookmark}
\usepackage{hyperref}
%
\setlength{\unitlength}{1mm} % 1mm=2.834646pt; 1pt=0.3515mm
%
%\frontmatter 5<--- here it hasn't any function
\captionsetup[subfigure]{labelformat=parens}
\begin{document}
The border at the top of the graphic changes according to whether dvi or pdf is chosen.
It is the pdf that I want to finish - with a uniform border.
\begin{figure}[h]
\begin{tcolorbox}[colframe=DarkRed,colback=DarkCream]
\centering
\begin{tabular}{@{}c@{\hspace{2em}}c@{}}
\includegraphics[width=0.45\hsize]{example-image-a}
&
\includegraphics[width=0.45\hsize]{example-image-b} \\
\parbox{0.45\hsize}{\captionof{subfigure}{Inequality region \label{fig:inequalityregion}}}
&
\parbox{0.45\hsize}{\captionof{subfigure}{Proof of inequality \label{fig:inequalityproof}}}
\end{tabular}
\end{tcolorbox}
\caption{Region satisfying the inequality}
\label{fig:twodiminequalityregion}
\end{figure}
\end{document}
如您所见,我只定义了框架和背景的颜色,其他参数的选择则subfigures
留给tcolorbox
您。对于子标题,我使用captionof
caption 包的功能,这样就可以在浮动环境之外使用它。
编辑(2): 我选择的图像间距离和图像与图像之间的距离大致平衡。这些距离由以下因素控制:
图像之间的宽度为 @{\hspace{}},
<width>
您可以根据自己的喜好进行选择。如果提供的距离\tabcolsep
足够,则应省略。图片和子标题之间的距离由 控制
\arraystrech
。这里我使用默认设置表格与边框之间的距离
tcolorbox
由其设置决定。我使用默认值,但您可以定义其他值,例如top=1mm, bottom=1mm, left=1mm, right=1mm,
如果您希望边框和图像之间的距离仅为 1 毫米。您还可以定义宽度tcolorox
。使用的默认设置为textwidth
。有关详细信息,请参阅红色tcolorbox
手册。