1
%
\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}
  • your code can not be compiled and hyperref have nothing with this. In figure is completely wrong. you can not put subloat into node! Later I will try to clean-up your code. – Zarko Sep 15 '15 at 16:06
  • Sorry Zarko, it appears to compile (with no errors) on MikTex 2.9 - I've just double-checked. – keith77777 Sep 15 '15 at 16:11
  • Removing the \hyperref cures the problem - but, of course, I need hyperref. – keith77777 Sep 15 '15 at 16:13
  • I get the same output with pdflatex and latex. Not sure what's the question. – egreg Sep 15 '15 at 16:24
  • @Zarko Works fine here. And why do you say that a \subfloat can't be placed within a node? – Torbjørn T. Sep 16 '15 at 7:40
1

As I mentioned in my comment, I can not compile your code. So I rearrange it on the way, as I usually manage similar situation.

  • any package in which is used in document I load only one
  • package with option (as caption, subfig,...) I load separately

Your construction of figure is very unusual and I doubt that the can be compiled (well, some comment report differently). So I rearrange your code as follows:

\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}

Which gives with pdflatex the following image:

enter image description here

Is this what you looking for?

Edit: Well, above solution seems not to be, what you looking for. Is then this one?

enter image description here

For it I use the following code:

\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}

As you can see, I put subfigures in tcolorbox where I only define color of frame and background and left selection of other parameters to you. For sub captions I use captionof facility of caption package, which enable to use it outside of float environment.

Edit (2): Distance between images and between images I select such that they are approximately balanced. This distances are controlled by:

  • between images width @{\hspace{}}, where <width> you can select according to your taste. If the distance provided by \tabcolsep is adequate, than it should be omitted.

  • distance between images and sub captions is controlled by \arraystrech. Here I use default settings

  • distance between table and border of tcolorbox is determined by its settings. I use default value, but you can define other values, for example

    top=1mm, bottom=1mm, left=1mm, right=1mm,

if you like to have only 1 mm distance between border and images. You can also define width of tcolorox. Used default setting is textwidth. For details please red tcolorbox manual.

  • It looks good but I cannot check properly tonight (UK). – keith77777 Sep 15 '15 at 18:49
  • The problem was that the border at the top - while being correct in the dvi compilation, then increased by at least 20pt under the pdf compilation. Everything else remained consistent under both compilations. I think your answer solves the problem. Thanks for the moment. – keith77777 Sep 15 '15 at 18:54
  • Zarko, I see you have placed two separate background borders - one around each picture. Would it be difficult to use one border around the pair, please? – keith77777 Sep 15 '15 at 22:20
  • I have tried to adapt your syntax to get a single background for the pair of pics but, so far, to no avail. However, I am convinced your method will work. – keith77777 Sep 16 '15 at 1:09
  • @keith77777, you mean that sub-caption is also included in single colored frame? This is with given example is not possible. For it you (me?) need to look for different approach. – Zarko Sep 16 '15 at 5:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.