4

In one of my .tex file, I have the following code which puts 2 minipages side by side, the whole width cover two minipages:

\documentclass[11pt, a4paper]{article}
\setlength{\topmargin}{-.5in}
\setlength{\textheight}{9in}
\setlength{\oddsidemargin}{.125in}
\setlength{\textwidth}{6.25in}

% \documentclass[runningheads,orivec]{llncs}

\input{fonts.tex}
\input{macros.tex}
\usepackage{caption}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{bbm}
\usepackage{bm}
\usepackage{empheq}
\usepackage{framed}
\usepackage{mathbbol}
\usepackage{color}
\usepackage{float}
\usepackage{caption,subcaption}%
\usepackage{calc}% http://ctan.org/pkg/calc
\usepackage{hyperref}
\usepackage{mathtools}
\usepackage{algpseudocode}
\usepackage{multicol}
\usepackage{longtable}
\usepackage{listings,xcolor,lipsum}

\usepackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,arrows}

\begin{document}
bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla\\
\noindent\begin{minipage}[t]{0.48\linewidth}%
  \centering
    \begin{minipage}[t]{\linewidth-2\fboxsep-2\fboxrule}%
      \hspace*{0em}{\begin{tikzpicture}[thick, scale=0.6]
          \filldraw[fill=white!20] (2,0) rectangle (10,2);
          \filldraw[fill=white!20] (2,5) rectangle (6,12);
          \filldraw[fill=white!20] (6,5) rectangle (10,12);
        \end{tikzpicture}}
    \end{minipage}
\end{minipage}\hfill
\begin{minipage}[t]{0.48\linewidth}%
  \centering
    \begin{minipage}[t]{\linewidth-2\fboxsep-2\fboxrule}%
      \raisebox{0em}{\begin{tikzpicture}[thick, scale=0.6]
          \filldraw[fill=white!20] (2,0) rectangle (6,7);
          \filldraw[fill=white!20] (8,0) rectangle (12,7);
          \filldraw[fill=white!20] (2,-5) rectangle (12,-3);
        \end{tikzpicture}}
    \end{minipage}
\end{minipage}\\
bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
\end{document}

In a new .tex file, I need to use \documentclass[runningheads,orivec]{llncs}, so I remove all the \setlength, with the same code, the minipages are a little bit too large, and do not respect the border on the right...

Does anyone know which parameter I need to change so that the 2 minipages respect the width of the article?

Edit1: Sorry guys, you could finally try the code above and switch between article and llncs. You will see that for llncs, the minipages exceed a little bit the border on the right... Could we amend that?

3
  • 2
    Please consider expanding your code into a compilable MWE.
    – Mico
    Feb 28, 2012 at 23:09
  • I don't see any overflow.
    – egreg
    Feb 28, 2012 at 23:34
  • I have added more packages that I use, maybe they raise the problem?
    – SoftTimur
    Feb 28, 2012 at 23:45

1 Answer 1

5

The problem is that your tikzpicture is too big for the minipage. I added \usepackage{showframe} so that we can see where the margins are.

As you can see from the two minipages of text, things fit fine. Only with the tikzpicture do you have the overflow. Hence you need to reduce the size of your picture by adjusting the scale.

enter image description here

Notes:

  • Using \showthe\linewidth, we see that the \linewidth=451.6875pt for the article class, and \linewidth=347.12354pt with the llncs class. This reduction in the width is what is causing the pictures to no longer fit within the minipage and flow into the margin.
  • The geometry package changes the \linewidth and hence the problem does not show up if you use \usepackage[showframe]{geometry}.

Code:

%\documentclass[11pt, a4paper]{article}
%\setlength{\topmargin}{-.5in}
%\setlength{\textheight}{9in}
%\setlength{\oddsidemargin}{.125in}
%\setlength{\textwidth}{6.25in}

\documentclass[runningheads,orivec]{llncs}

\usepackage{showframe}
\usepackage{calc}
\usepackage{tikz}

\newcommand{\Text}{%
bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla}

\begin{document}
%\showthe\linewidth
\noindent\begin{minipage}{0.48\linewidth-2\fboxsep-2\fboxrule}
    \Text
\end{minipage}
\hfill
\noindent\begin{minipage}{0.48\linewidth-2\fboxsep-2\fboxrule}
    \Text
\end{minipage}


\bigskip\noindent
\Text

\noindent\begin{minipage}[t]{0.48\linewidth}%
  \centering
    \begin{minipage}[t]{\linewidth-2\fboxsep-2\fboxrule}%
      \hspace*{0em}{\begin{tikzpicture}[thick, scale=0.6]
          \filldraw[fill=red!20] (2,0) rectangle (10,2);
          \filldraw[fill=blue!20] (2,5) rectangle (6,12);
          \filldraw[fill=green!20] (6,5) rectangle (10,12);
        \end{tikzpicture}}
    \end{minipage}%
\end{minipage}\hfill%
\begin{minipage}[t]{0.48\linewidth}%
  \centering
    \begin{minipage}[t]{\linewidth-2\fboxsep-2\fboxrule}%
      \raisebox{0em}{\begin{tikzpicture}[thick, scale=0.6]
          \filldraw[fill=brown!20] (2,0) rectangle (6,7);
          \filldraw[fill=orange!20] (8,0) rectangle (12,7);
          \filldraw[fill=violet!20] (2,-5) rectangle (12,-3);
        \end{tikzpicture}}
    \end{minipage}
\end{minipage}%

\noindent\Text
\end{document}
3
  • Thanks for your answer... I have got the same image as you after adding showframe, with or without fonts.tex and macros.tex. However, without showframe, the minipage still exceeds the right border, with or without the tex files... By the way, I use llncs instead of llncs2e/llncs...
    – SoftTimur
    Feb 29, 2012 at 1:36
  • Ok, have updated the answer - your pictures were too big. The llncs2e/llncs was just an artifact of where I downloaded the class to. And \usepacakge{showframe} seems to show the problem without changing the size as the geometry package was doing. Feb 29, 2012 at 2:06
  • This is the first time I've seen showframe. Thanks! Feb 29, 2012 at 3:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .