小页面左侧位置

小页面左侧位置

我正在尝试将优化问题放在一个框内。经过一番研究,我发现了这个方法(如果您知道更好的方法,请随意提出更好的方法):

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

但是我想将框定位在文本左边距的 5% 处(因为框是文本宽度的 110%)。
如果我尝试使用\begin{center}之前的\begin{tikzpicture}方法,它似乎无法按我想要的方式工作。

那我该怎么办呢?

答案1

你可以使用adjustbox类似

\begin{adjustbox}{center}

content

\end{adjustbox}

代码:

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

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


\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{adjustbox}{center}
\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}
\end{adjustbox}

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}

在此处输入图片描述

答案2

再次尝试tcolorbox使用计数器,然后您就可以给它贴上标签。

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

在此处输入图片描述

相关内容