# Left position of minipage

I'm trying to put an optimization problem inside a box. After some research I found this method (please fill free to propose a better method if you know something better):

\documentclass[11pt,a4paper,twoside,openright]{report}

\usepackage{tikz}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{color}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{verbatim}
\usepackage{caption}

\definecolor{mygray}{rgb}{0.9,0.9,0.9} % cyan
\tikzstyle{mybox} = [draw=black, fill=mygray!20, very thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=5pt]
\tikzstyle{fancytitle} =[draw=black,   thick, fill=white, text=black]

\usepackage{tikz}
\usepackage{pgfplots}

\captionsetup{font=scriptsize,labelfont=scriptsize}

\begin{document}
\section{Some Title}
Some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text.
\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{1.1\textwidth}
\begin{align}
\label{eqn:LCP}
\sum_{k \in A_b} \rho^b_k U_a(j,k) + r^a_j = v_a &\;&\;&  \forall j \in A_a, \forall a,b \in \Psi, b \neq a \\
\sum_{j \in A_a} \rho^a_j = 1 &\;&\;& \forall a \in \Psi \\
\rho^a_j \geq 0    &\;&\;& \forall j \in A_a, \forall a \in \Psi \\
r^a_j \geq 0   &\;&\;& \forall j \in A_a, \forall a \in \Psi \\
\label{eqn:LCPcomplementarity}
\rho^a_jr^a_j = 0  &\;&\;& \forall j \in A_a, \forall a \in \Psi
\end{align}
\end{minipage}
};
\node[fancytitle, right=10pt] at (box.north west) {Some LCP};
\end{tikzpicture}

Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text.
\end{document}


However I want to position the box 5% left of the left margin of the text (as the box is 110% of text width).
If I try to use \begin{center} before \begin{tikzpicture} it seems not working as I want.

What can I do, then?

-
Welcome to TeX.SX! – Adam Liter Feb 18 '14 at 15:12

You can use adjustbox like

\begin{adjustbox}{center}

content



Code:

\documentclass[11pt,a4paper,twoside,openright]{report}

\usepackage{tikz}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{color}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{verbatim}
\usepackage{caption}

\definecolor{mygray}{rgb}{0.9,0.9,0.9} % cyan
\tikzstyle{mybox} = [draw=black, fill=mygray!20, very thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=5pt]
\tikzstyle{fancytitle} =[draw=black,   thick, fill=white, text=black]

\usepackage{tikz}
\usepackage{pgfplots}

\captionsetup{font=scriptsize,labelfont=scriptsize}

\begin{document}
\section{Some Title}
Some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text.

\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{1.1\textwidth}
\begin{align}
\label{eqn:LCP}
\sum_{k \in A_b} \rho^b_k U_a(j,k) + r^a_j = v_a &\;&\;&  \forall j \in A_a, \forall a,b \in \Psi, b \neq a \\
\sum_{j \in A_a} \rho^a_j = 1 &\;&\;& \forall a \in \Psi \\
\rho^a_j \geq 0    &\;&\;& \forall j \in A_a, \forall a \in \Psi \\
r^a_j \geq 0   &\;&\;& \forall j \in A_a, \forall a \in \Psi \\
\label{eqn:LCPcomplementarity}
\rho^a_jr^a_j = 0  &\;&\;& \forall j \in A_a, \forall a \in \Psi
\end{align}
\end{minipage}
};
\node[fancytitle, right=10pt] at (box.north west) {Some LCP};
\end{tikzpicture}

Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text.
\end{document}


-
Thank you very much! The solution is very simple but if I had to learn it by myself it would have taken some hours or days! – HAL9000 Feb 18 '14 at 15:05
Excuse me, how can I install adjustbox? I downloaded it from ctan, I copied it into latex folder, I did latex adjustbox.ins but it complains about ydocstrip.tex. What's the correct way to install it? – HAL9000 Feb 18 '14 at 15:21
@HAL9000: Use your tex package manager. – Harish Kumar Feb 18 '14 at 15:26
@HAL9000 The adjustbox package can be avoided by placing the tikzpicture in the following construct: \centering\makebox[0pt]{\begin{tikzpicture}...\end{tikzpicture}}\par. – Steven B. Segletes Feb 18 '14 at 16:05
@HAL9000 Yes, I forgot... place a left brace { before the \centering and a right brace } after the \par. That will limit the extent of the \centering to the braced content. – Steven B. Segletes Feb 18 '14 at 17:04

Another attempt with tcolorbox with a counter and you can label it.

\documentclass[11pt,a4paper,twoside,openright]{report}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{color}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{verbatim}
\usepackage{caption}

\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable}
\newcounter{example}
\newtcolorbox[use counter=example]{FancyTitle}[3][]{%
enhanced,colback=blue!10!white,colframe=orange,top=4mm,
enlarge top by=\baselineskip/2+1mm,
width=1.1\textwidth,
oversize,
enlarge top at break by=0mm,pad at break=2mm,
fontupper=\normalsize,label={#3},
overlay unbroken and first={%
\node[rectangle,rounded corners,draw=black,fill=green!30!white,
inner sep=1mm,anchor=west,font=\small]
at ([xshift=4.5mm]frame.north west)
{\strut\textbf{LCP \thetcbcounter: #2}};},
#1}%
%\begin{FancyTitle}{<title>}{<label>}
%<content>
%\end{FancyTitle}

\captionsetup{font=scriptsize,labelfont=scriptsize}

\begin{document}
\section{Some Title}
Some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. some text.

\begin{FancyTitle}{Some LCP}{fancy:LCP}
\begin{align}
\label{eqn:LCP}
\sum_{k \in A_b} \rho^b_k U_a(j,k) + r^a_j = v_a &\;&\;&  \forall j \in A_a, \forall a,b \in \Psi, b \neq a \\
\sum_{j \in A_a} \rho^a_j = 1 &\;&\;& \forall a \in \Psi \\
\rho^a_j \geq 0    &\;&\;& \forall j \in A_a, \forall a \in \Psi \\
r^a_j \geq 0   &\;&\;& \forall j \in A_a, \forall a \in \Psi \\
\label{eqn:LCPcomplementarity}
\rho^a_jr^a_j = 0  &\;&\;& \forall j \in A_a, \forall a \in \Psi
\end{align}
\end{FancyTitle}

Other text in LCP~\ref{fancy:LCP}. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text. Other text.
\end{document}


-
Now my answer seems redundant. I'll delete it. – Gonzalo Medina Feb 18 '14 at 15:32
@GonzaloMedina Oh No. I spent some time on this. Hence though I saw your answer, since mine had some extra features, I thought I will add it. Really sorry. :( – Harish Kumar Feb 18 '14 at 15:33