小页面标题放置错误

小页面标题放置错误

我在放置小页面的子标题和标题时遇到了问题。图片描述了我想要的内容,但图形包含在一个图表中。也许,正确的解决方案不是\picture之前的邮政。 我希望你可以帮助我。

我是

\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{calc}
\usepackage{lmodern}
\usepackage{lipsum}
\usepackage{graphicx,picture,calc}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usetikzlibrary{patterns}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\centering
\begin{minipage}{0.4\linewidth}
\centering
\begin{tikzpicture}
\begin{axis}[ymin=0,xmin=-20000,x=.001mm,y=1cm, axis x line=bottom,axis y line=left,ylabel={\scriptsize TEXT},clip=false]
    \addplot[mark=none,very thick,red] coordinates{(0,8)(1873,8)(845,7)(3504,7)(1358,6)(4127,6)(1384,5)(4057,5)(1458,4)(3366,4)(2243,3)(1828.5,3)(4189,2)(1710,2)(7393,1)(5661,1)(11723,0)};
    \addplot+[mark=none,fill,pattern=north east lines] coordinates{(0,8)(1873,8)(845,7)(3504,7)(1358,6)(4127,6)(1384,5)(4057,5)(1458,4)(3366,4)(2243,3)(1828.5,3)(4189,2)(1710,2)(7393,1)(5661,1)(11723,0)}\closedcycle;
    \addplot[mark=none]coordinates{(0,0)(0,8)};
\node at (axis cs:1873,8.15) [font=\scriptsize, right] {1873};
\node at (axis cs:3504,7.15) [font=\scriptsize, right] {3504};
\node at (axis cs:4127,6.15) [font=\scriptsize, right] {4127};
\node at (axis cs:4057,5.15) [font=\scriptsize, right] {4057};
\node at (axis cs:3366,4.15) [font=\scriptsize, right] {3366};
\node at (axis cs:2243,3.15) [font=\scriptsize, right] {2243};
\node at (axis cs:4189,2.15) [font=\scriptsize, right] {4189};
\node at (axis cs:7393,1.15) [font=\scriptsize, right] {7393};
\node at (axis cs:11723,0.15) [font=\scriptsize, right] {11723};
    \end{axis}
    \end{tikzpicture}
    \subcaption{Subcaption}
\end{minipage}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{minipage}{0.4\linewidth}
\centering
\sbox0{
\begin{tikzpicture}[scale=.3]
\draw (0,0)--(0,.4)--(1.575,.4)--(1.575,7.8)--(0,7.8)--(0,8.2)--(3.4,8.2)--(3.4,7.8)--(1.825,7.8)--(1.825,.4)--(3.4,.4)--(3.4,0)--cycle;
\end{tikzpicture}
}
\sbox2{
\begin{tikzpicture}
\begin{axis}[ymin=0,x=.001mm,y=1cm, axis x line=bottom,axis y line=left,hide y axis,clip=false]
    \addplot[mark=none,red,very thick] coordinates{(0,8)(287,8)(2363,7)(2013,7)(6596,6)(6236,6)(12237,5)(11880,5)(19002,4)(18658,4)(26639,3)(26350,3)(34817,2)(34625,2)(43433,1)(43332,1)(51380,0)};
    \addplot+[mark=none,fill,pattern=north east lines] coordinates{(0,8)(287,8)(2363,7)(2013,7)(6596,6)(6236,6)(12237,5)(11880,5)(19002,4)(18658,4)(26639,3)(26350,3)(34817,2)(34625,2)(43433,1)(43332,1)(51380,0)}\closedcycle;
    \addplot [mark=none]coordinates{(0,0)(0,8)};
\node at (axis cs:287,8.15) [font=\scriptsize, right] {287};
\node at (axis cs:2363,7.15) [font=\scriptsize, right] {2363};
\node at (axis cs:6596,6.15) [font=\scriptsize, right] {6596};
\node at (axis cs:12237,5.15) [font=\scriptsize, right] {12237};
\node at (axis cs:19002,4.15) [font=\scriptsize, right] {19002};
\node at (axis cs:26639,3.15) [font=\scriptsize, right] {26639};
\node at (axis cs:34817,2.15) [font=\scriptsize, right] {34817};
\node at (axis cs:43433,1.15) [font=\scriptsize, right] {43433};
\node at (axis cs:51380,0.15) [font=\scriptsize, right] {51380};
    \end{axis}
    \end{tikzpicture}
    }
\begin{picture}(\wd0, \ht0 )
\put(0,0){\usebox0}
%% Adjust the -0.7cm and -0.5cm shifts
\put(\wd0 - \wd2 - 0.5cm,\ht0 - \ht2 - 0.1cm){\usebox{2}}
\end{picture}
    \subcaption{Subcaption}
\end{minipage}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\caption{Caption}
\end{figure}

\end{document}

答案1

在您的例子中,较小的一个\sbox被用作图片内的参考,因此您的对齐被破坏了。\centering内部的 造成了进一步的破坏minipage,这似乎导致点(0,0)被移动。 最后,我为小页面提供了对齐说明符,即[b]

以下应该有效:

在此处输入图片描述

\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{calc}
\usepackage{lmodern}
\usepackage{lipsum}
\usepackage{graphicx,picture,calc}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usetikzlibrary{patterns}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\centering
\begin{minipage}[b]{0.4\linewidth}
\centering
\begin{tikzpicture}
\begin{axis}[ymin=0,xmin=-20000,x=.001mm,y=1cm, axis x line=bottom,axis y line=left,ylabel={\scriptsize TEXT},clip=false]
    \addplot[mark=none,very thick,red] coordinates{(0,8)(1873,8)(845,7)(3504,7)(1358,6)(4127,6)(1384,5)(4057,5)(1458,4)(3366,4)(2243,3)(1828.5,3)(4189,2)(1710,2)(7393,1)(5661,1)(11723,0)};
    \addplot+[mark=none,fill,pattern=north east lines] coordinates{(0,8)(1873,8)(845,7)(3504,7)(1358,6)(4127,6)(1384,5)(4057,5)(1458,4)(3366,4)(2243,3)(1828.5,3)(4189,2)(1710,2)(7393,1)(5661,1)(11723,0)}\closedcycle;
    \addplot[mark=none]coordinates{(0,0)(0,8)};
\node at (axis cs:1873,8.15) [font=\scriptsize, right] {1873};
\node at (axis cs:3504,7.15) [font=\scriptsize, right] {3504};
\node at (axis cs:4127,6.15) [font=\scriptsize, right] {4127};
\node at (axis cs:4057,5.15) [font=\scriptsize, right] {4057};
\node at (axis cs:3366,4.15) [font=\scriptsize, right] {3366};
\node at (axis cs:2243,3.15) [font=\scriptsize, right] {2243};
\node at (axis cs:4189,2.15) [font=\scriptsize, right] {4189};
\node at (axis cs:7393,1.15) [font=\scriptsize, right] {7393};
\node at (axis cs:11723,0.15) [font=\scriptsize, right] {11723};
    \end{axis}
    \end{tikzpicture}
    \subcaption{Subcaption}
\end{minipage}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{minipage}[b]{0.55\linewidth}
%\centering
\sbox0{
\begin{tikzpicture}[scale=.2]
\draw (0,0)--(0,.4)--(1.575,.4)--(1.575,7.8)--(0,7.8)--(0,8.2)--(3.4,8.2)--(3.4,7.8)--(1.825,7.8)--(1.825,.4)--(3.4,.4)--(3.4,0)--cycle;
\end{tikzpicture}
}
\sbox2{
\begin{tikzpicture}
\begin{axis}[ymin=0,x=.001mm,y=1cm, axis x line=bottom,axis y line=left,hide y axis,clip=false]
    \addplot[mark=none,red,very thick] coordinates{(0,8)(287,8)(2363,7)(2013,7)(6596,6)(6236,6)(12237,5)(11880,5)(19002,4)(18658,4)(26639,3)(26350,3)(34817,2)(34625,2)(43433,1)(43332,1)(51380,0)};
    \addplot+[mark=none,fill,pattern=north east lines] coordinates{(0,8)(287,8)(2363,7)(2013,7)(6596,6)(6236,6)(12237,5)(11880,5)(19002,4)(18658,4)(26639,3)(26350,3)(34817,2)(34625,2)(43433,1)(43332,1)(51380,0)}\closedcycle;
    \addplot [mark=none]coordinates{(0,0)(0,8)};
\node at (axis cs:287,8.15) [font=\scriptsize, right] {287};
\node at (axis cs:2363,7.15) [font=\scriptsize, right] {2363};
\node at (axis cs:6596,6.15) [font=\scriptsize, right] {6596};
\node at (axis cs:12237,5.15) [font=\scriptsize, right] {12237};
\node at (axis cs:19002,4.15) [font=\scriptsize, right] {19002};
\node at (axis cs:26639,3.15) [font=\scriptsize, right] {26639};
\node at (axis cs:34817,2.15) [font=\scriptsize, right] {34817};
\node at (axis cs:43433,1.15) [font=\scriptsize, right] {43433};
\node at (axis cs:51380,0.15) [font=\scriptsize, right] {51380};
    \end{axis}
    \end{tikzpicture}
    }
\begin{picture}(\wd0, \ht0 )
\put(0,0){\usebox2}
%% Adjust the -0.7cm and -0.5cm shifts
\put(\wd2 - \wd0 - 1cm,\ht2 - \ht0 - 1cm){\usebox{0}}
\end{picture}
    \subcaption{Subcaption}
\end{minipage}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\caption{Caption}
\end{figure}

\end{document}

相关内容