2
  1. I tried centering horizontally using the "adjustwidth" environment, but unfortunately, it's not very accurate. Also my captions are not centered under my figures anymore.

  2. I have no idea how to use the area above my minipage. I tried using vspace, but I can't seem to move the minipage upwards.

Following image illustrates my issue:

the problem

Following piece of code (MWE) shows what I tried to do:

\documentclass[11pt, a4paper, openright]{book} %oneside option
\usepackage{etex}
\usepackage{tocbibind}

%PACKAGES
%\usepackage{times}
\usepackage[dvips]{graphicx}
\usepackage{chngpage}
\usepackage{url}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[all]{xy}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{psfrag} %laprint
\usepackage{color}
\usepackage[usenames]{xcolor}
\usepackage[pdf,usenames,dvipsnames]{pstricks}
\usepackage{tikz}
\usepackage{auto-pst-pdf}
\usepackage{epsfig}
\usepackage{pst-grad} % For gradients
\usepackage{pst-plot} % For axes
\usepackage{epstopdf}
\usepackage{float}
\usepackage{pdfpages}
\usepackage{subfigure}
\usepackage{mathabx}
\usepackage[chapter]{algorithm}
\usepackage[small,bf,hang]{caption}
\renewcommand{\captionfont}{\small\itshape}
\usepackage{natbib}
\bibpunct{[}{]}{;}{n}{,}{,}     % Numerical system
\usepackage{listings}

%LAYOUT
\bibliographystyle{ieeetr}
\usepackage{chngcntr}
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{1}

\setlength{\textheight}{237mm} %A4 - 297
\setlength{\textwidth}{160mm} %A4 - 210
\setlength{\topmargin}{-0.54cm} %A4
\setlength{\headheight}{15pt} %A4
\setlength{\oddsidemargin}{0.46cm}  %A4 Centers text.
\setlength{\evensidemargin}{-.54cm} %A4

%
%Left margin 30 mm, right margin 20 mm, top margin 20 mm, bottom     margin 20 mm.
%2,54

\usepackage{fancyhdr}
\pagestyle{fancy}

% with this we ensure that the chapter and section
% headings are in lowercase.
\renewcommand{\chaptermark}[1]{%
\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{%
\markright{\thesection\ #1}}
\fancyhf{} % delete current header and footer


\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}

\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headheight}{0.5pt} % space for the rule
\fancypagestyle{plain}{%
\fancyhead{} % get rid of headers on plain pages
\renewcommand{\headrulewidth}{0pt} % and the line
}

\parskip 6pt           % sets spacing between paragraphs
\parindent 0pt       % sets leading space for paragraphs 

\newtheorem{definition}{Definition}[chapter]

\newenvironment{remark}[1][Remark]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}

\newcommand{\vectornorm}[1]{\|#1\|}

%Locally remove natural indent of itemize
\usepackage{enumitem}

\usepackage{hyperref}
\hypersetup{
    colorlinks,%
    citecolor=black,%
    filecolor=black,%
    linkcolor=black,%
    urlcolor=black
}

\begin{document}
\begin{figure}[p]
\makebox[\textwidth][c]{%
    \begin{minipage}[b]{0.565\linewidth}
        \centering
        \includegraphics[scale=0.7]{plots/Reflex_128_Plot_xRemovals_yCPUsecondsEncoding.eps} 
        \caption{Reflex: $128 \times 128$ - Encoder} 
        \label{plot:encoding_decoding_cpu_time_2a} 
    \end{minipage}%
    \begin{minipage}[b]{0.565\linewidth}
        \centering
        \includegraphics[scale=0.7]{plots/Reflex_128_Plot_xRemovals_yCPUsecondsDecoding.eps} 
        \caption{Reflex: $128 \times 128$ - Decoder}
        \label{plot:encoding_decoding_cpu_time_2b}  
    \end{minipage}}%

    \makebox[\textwidth][c]{%       
    \begin{minipage}[b]{0.565\linewidth}
        \centering
        \includegraphics[scale=0.7]{plots/Lena_128_Plot_xRemovals_yCPUsecondsEncoding.eps} 
        \caption{Lena: $128 \times 128$ - Encoder} 
        \label{plot:encoding_decoding_cpu_time_3a} 
    \end{minipage}%
    \begin{minipage}[b]{0.565\linewidth}
        \centering
        \includegraphics[scale=0.7]{plots/Lena_128_Plot_xRemovals_yCPUsecondsDecoding.eps} 
        \caption{Lena: $128 \times 128$ - Decoder} 
        \label{plot:encoding_decoding_cpu_time_3b} 
    \end{minipage}}%

    \makebox[\textwidth][c]{%
    \begin{minipage}[b]{0.565\linewidth}
        \centering
        \includegraphics[scale=0.7]{plots/Fruits_128_Plot_xRemovals_yCPUsecondsEncoding.eps} 
        \caption{Fruits: $128 \times 128$ - Encoder} 
        \label{plot:encoding_decoding_cpu_time_4a} 
    \end{minipage}%
    \begin{minipage}[b]{0.565\linewidth}
        \includegraphics[scale=0.7]{plots/Fruits_128_Plot_xRemovals_yCPUsecondsDecoding.eps}
        \centering 
        \caption{Fruits: $128 \times 128$ - Decoder}
        \label{plot:encoding_decoding_cpu_time_4b}  
    \end{minipage}}%
\end{figure}
\end{document}

Thanks in advance for your help!

2

As your minipages are bigger than half of the page, they will need some more place on both sides of the text. Just put every two minipages in a \makebox for this. (Not my recommendation. Try to fit everything in your margins as this will look more consistent over your whole report.)

For vertical centring, just use the [p] specifier of your figure. If you use [t] instead or none at all, it will be flushed to the top if followed by text. No need for \vspace.

Load caption in order to get better spacing between captions and following images.

% arara: pdflatex

\documentclass{article}
\usepackage[demo]{graphicx}
%\usepackage{changepage} % not needed any more
\usepackage{showframe} % just for demo
\usepackage{caption}

\begin{document}
\begin{figure}[p]
    \makebox[\textwidth][c]{%
        \begin{minipage}[b]{0.565\linewidth}
            \centering
            \includegraphics[scale=0.7]{plots/Reflex_128_Plot_xRemovals_yCPUsecondsEncoding.eps} 
            \caption{Reflex: $128 \times 128$ - Encoder} 
            \label{plot:encoding_decoding_cpu_time_2a} 
        \end{minipage}%
        \begin{minipage}[b]{0.565\linewidth}
            \centering
            \includegraphics[scale=0.7]{plots/Reflex_128_Plot_xRemovals_yCPUsecondsDecoding.eps} 
            \caption{Reflex: $128 \times 128$ - Decoder}
            \label{plot:encoding_decoding_cpu_time_2b}  
        \end{minipage}}%

        \makebox[\textwidth][c]{%       
        \begin{minipage}[b]{0.565\linewidth}
            \centering
            \includegraphics[scale=0.7]{plots/Lena_128_Plot_xRemovals_yCPUsecondsEncoding.eps} 
            \caption{Lena: $128 \times 128$ - Encoder} 
            \label{plot:encoding_decoding_cpu_time_3a} 
        \end{minipage}%
        \begin{minipage}[b]{0.565\linewidth}
            \centering
            \includegraphics[scale=0.7]{plots/Lena_128_Plot_xRemovals_yCPUsecondsDecoding.eps} 
            \caption{Lena: $128 \times 128$ - Decoder} 
            \label{plot:encoding_decoding_cpu_time_3b} 
        \end{minipage}}%

        \makebox[\textwidth][c]{%
        \begin{minipage}[b]{0.565\linewidth}
            \centering
            \includegraphics[scale=0.7]{plots/Fruits_128_Plot_xRemovals_yCPUsecondsEncoding.eps} 
            \caption{Fruits: $128 \times 128$ - Encoder} 
            \label{plot:encoding_decoding_cpu_time_4a} 
        \end{minipage}%
        \begin{minipage}[b]{0.565\linewidth}
            \includegraphics[scale=0.7]{plots/Fruits_128_Plot_xRemovals_yCPUsecondsDecoding.eps}
            \centering 
            \caption{Fruits: $128 \times 128$ - Decoder}
            \label{plot:encoding_decoding_cpu_time_4b}  
        \end{minipage}}%
\end{figure}
\end{document}

enter image description here

3
  • Hi @LaRiFaRi, thanks for your quick response. I editted my original post and created a minimal working example. Unfortunately, it's still not working. – MoGuL Aug 7 '15 at 12:36
  • 1
    @MoGuL This is far away from minimal. Please reduce. E.g. I can't find luximono. "It's still not working" is nothing, I can work with. What is not working? What are you expecting to get? What have you tried? Reduce your code until you see the problematic lines of code. – LaRiFaRi Aug 7 '15 at 12:50
  • I see your point, I will modify! Well I just get the exact same outcome, that's what's not working. – MoGuL Aug 7 '15 at 13:00
1

Another possibilities is to put pictures in table instead use minipages:

\documentclass{article}
    \usepackage{graphicx}
    \usepackage{showframe} % just for demo
\usepackage{tabularx} % added package
    \usepackage{caption}

    \begin{document}
\begin{figure}[p]
    \setlength{\tabcolsep}{2pt}% reduce space between columns in table
    \begin{tabularx}{\textwidth}{@{}*{2}{>{\centering\arraybackslash}X}@{}}
\includegraphics[width=1\hsize]{example-image}\newline
\caption{Reflex: $128 \times 128$ - Encoder}
\label{plot:encoding_decoding_cpu_time_2a}
&
    \includegraphics[width=1\hsize]{example-image}\newline
    \caption{Reflex: $128 \times 128$ - Decoder}
    \label{plot:encoding_decoding_cpu_time_2b}
            \\
\includegraphics[width=\hsize]{example-image}\newline
\caption{Lena: $128 \times 128$ - Encoder}
\label{plot:encoding_decoding_cpu_time_3a}
&
    \includegraphics[width=\hsize]{example-image}\newline
    \caption{Lena: $128 \times 128$ - Decoder}
    \label{plot:encoding_decoding_cpu_time_3b}
            \\
\includegraphics[width=\hsize]{example-image}\newline
\caption{Fruits: $128 \times 128$ - Encoder}
\label{plot:encoding_decoding_cpu_time_4a}
&   
    \includegraphics[width=\hsize]{example-image}\newline
    \caption{Fruits: $128 \times 128$ - Decoder}
    \label{plot:encoding_decoding_cpu_time_4b}
        \end{tabularx}%
\end{figure}
    \end{document}

This solution require to load package tabularx, however benefits is more simple and concise code. Results is similar as show LaRiFari in his answer:

enter image description here

Edit: The widths of images is determined with [width=\hsize] and limited with space in cells. For enlarge this spaces reduce tabcolsep and eliminate it on beginning and end of table with @{} (see modified code).

Further reducing vertical white space with preserved aspect ratio of images is only possible with locally enlarged text width with use of \usepackage{changepage}. I do not know, if this can came to account.

1
  • Hi @Zarko, thanks for your response! This is indeed a bit closer to what I aim for. The problem is that I still have a lot of white space around my images. I would like to make them as big as possible, so that they fill they entire page, both vertically and horizontally. Any tips on that? – MoGuL Aug 7 '15 at 12:54
0

You can totally get rid of the figure environment and have full control, but you will be also totally responsible for the final output. Here is an implementation with the \captionof command from the caption package that will enable you of using the largest possible space horizontally and vertically. tabularx will still be very useful.

\documentclass{article}
\usepackage{graphicx}
\usepackage{showframe} % just for demo
\usepackage{tabularx} % added package
\usepackage{caption}
\begin{document}

\setlength{\tabcolsep}{2pt}% reduce space between columns in table
\newcommand{\HT}{4.88cm}
\noindent
\begin{tabularx}{\textwidth}{@{}*{2}{>{\centering\arraybackslash}X}@{}}
    \includegraphics[width=1\hsize,height=\HT]{example-image-A}\newline
    \captionof{figure}{Reflex: $128 \times 128$ - Encoder}
    \label{plot:encoding_decoding_cpu_time_2a}
&
    \includegraphics[width=1\hsize,height=\HT]{example-image-B}\newline
    \captionof{figure}{Reflex: $128 \times 128$ - Decoder}
    \label{plot:encoding_decoding_cpu_time_2b}
            \\
    \includegraphics[width=\hsize,height=\HT]{example-image-C}\newline
    \captionof{figure}{Lena: $128 \times 128$ - Encoder}
    \label{plot:encoding_decoding_cpu_time_3a}
&
    \includegraphics[width=\hsize,height=\HT]{example-image-A}\newline
    \captionof{figure}{Lena: $128 \times 128$ - Decoder}
    \label{plot:encoding_decoding_cpu_time_3b}
            \\
    \includegraphics[width=\hsize,height=\HT]{example-image-B}\newline
    \captionof{figure}{Fruits: $128 \times 128$ - Encoder}
    \label{plot:encoding_decoding_cpu_time_4a}
&   
    \includegraphics[width=\hsize,height=\HT]{example-image-C}\newline
    \captionof{figure}{Fruits: $128 \times 128$ - Decoder}
    \label{plot:encoding_decoding_cpu_time_4b}
\end{tabularx}%

\end{document}

enter image description here

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.