将多行中的 tikzpicture 对齐到顶部

将多行中的 tikzpicture 对齐到顶部

我想将下图所示的图对齐到顶部,以便与旁边的“微笑”图片对齐。我尝试了不同的方法,但都没有成功。也许你知道对齐是如何工作的?我尝试了:

  • \begin{tikzpicture}[baseline={([yshift={-\ht\strutbox}]当前边界框.北)}]....
  • 在表格环境中使用“p”代替“m”
  • 改变 tikzpicture 的高度
  • 尽量避免多行,但我无法找到另一种方法来很好地组织图形和六张图片(包括编号) - 但也许你知道另一种方法?

非常感谢你的帮助!Simone

以下是代码:

\documentclass[
twoside,openright,titlepage,numbers=noenddot,headinclude,
footinclude=true,cleardoublepage=empty,
dottedtoc, 
BCOR=5mm,paper=a4,fontsize=11pt, 
ngerman,american, 
floatperchapter, 
]{scrreprt} 

\usepackage{tikz,pgfplots}
\usepackage{calc}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{graphicx}

\begin{document}
    
\begin{figure}[bth]
    \small
    \centering
    \noindent\begin{tabular}{m{6.0cm}m{0.1cm}m{1.8cm}m{0.1cm}m{1.8cm}}
        {(a)} & {(b)} &  & & \\
        \multirow{3}{*}{
            \begin{tikzpicture}[font=\small]
                \begin{axis}[
                    width=6cm,
                    height=6.8cm,               
                    xmin=800,xmax=990, 
                    scaled ticks=false, 
                    xticklabel style={/pgf/number format/.cd,fixed,zerofill,precision=0,use comma},
                    xtick={850,900,950}, 
                    ymin=0,ymax=0.14, 
                    yticklabel style={/pgf/number format/.cd,fixed,zerofill,precision=2,use comma},
                    ytick={0.04,0.12}, 
                    xlabel={Data x values},
                    ylabel={Data y values},
                    ]
                    \addplot+ [
                    sharp plot,only marks,
                    ]
                    coordinates {
                        (956.7818,0.0207)
                        (906.6738,0.0075)
                        (891.8467,0.0039)
                        (933.3216,0.2029)
                        (832.1925,0.4017)
                        (945.5146,0.2317)
                        (947.2539,0.0414)
                        (880.3353,0.1197)
                        (863.7405,0.0711)
                        (853.8516,0.0338)
                        (884.8370,0.0013)
                        (910.5405,0.0461)};
                \end{axis}          
            \end{tikzpicture}
        }
        & 
        (1) & \includegraphics[width=1.8cm]{smile.jpg} & 
        (2) &  \includegraphics[width=1.8cm]{smile.jpg} \\
        & 
        (3) & \includegraphics[width=1.8cm]{smile.jpg} & 
        (4) &  \includegraphics[width=1.8cm]{smile.jpg} \\
        & 
        (5) & \includegraphics[width=1.8cm]{smile.jpg} & 
        (6) &  \includegraphics[width=1.8cm]{smile.jpg} \\
    \end{tabular}
\end{figure}

\end{document}

目前的情况如下: 在此处输入图片描述

答案1

编辑:

  • 使用两个顶部对齐的表格,其中第一个图表手动向下移动以根据试验确定的数量。
  • 第二张表中的图像通过使用adjust包将其基线移动到垂直中心:
\documentclass[
twoside,openright,titlepage,numbers=noenddot,headinclude,
footinclude=true,cleardoublepage=empty,
dottedtoc,
BCOR=5mm,paper=a4,fontsize=11pt,
ngerman,american,
floatperchapter,
]{scrreprt}

\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
%\usepackage{calc}
\usepackage{multirow, tabularx}
\usepackage[export]{adjustbox}    % it load graphicx too

\begin{document}
    \begin{figure}[htb]
    \small
    \centering
    \adjustboxset{height=19mm,valign=c, margin=0pt 3pt 0pt 3pt}
\begin{tabular}[t]{l}
    (a)     \\[4ex]
    \begin{tikzpicture}
\begin{axis}[font=\small,
    width=6cm,
    height=6.8cm,
    xmin=800,xmax=990,
    xtick={850,900,950},
    ymin=0, ymax=0.14,
    yticklabel style={/pgf/number format/.cd,fixed,zerofill,precision=2,use comma},
    ytick={0.04,0.12},
    xlabel={Data x values},
    ylabel={Data y values},
    ]
    \addplot+ [sharp plot,only marks]   coordinates {
        (956.7818,0.0207)
        (906.6738,0.0075)
        (891.8467,0.0039)
        (933.3216,0.2029)
        (832.1925,0.4017)
        (945.5146,0.2317)
        (947.2539,0.0414)
        (880.3353,0.1197)
        (863.7405,0.0711)
        (853.8516,0.0338)
        (884.8370,0.0013)
        (910.5405,0.0461)};
\end{axis}
    \end{tikzpicture}
\end{tabular}\begin{tabular}[t]{*{4}{l}}
    (b) &&& \\
    (1) & \adjustimage{}{example-image-duck}%{smile.jpg}
        &   (2) & \adjustimage{}{example-image-duck}%{smile.jpg}
        \\
    (3) & \adjustimage{}{example-image-duck}%{smile.jpg}
        &   (4) & \adjustimage{}{example-image-duck}%{smile.jpg}
        \\
    (5) & \adjustimage{}{example-image-duck}%{smile.jpg}
        &   (6) & \adjustimage{}{example-image-duck}%{smile.jpg}
\end{tabular}
    \end{figure}
\end{document}

笔记:图表比您的笑脸图像高(您应该告诉我们在哪里可以找到它们),因此在 MWE 中规定了它们的高度(19 毫米),它们共同给出了图表的近似高度。

在此处输入图片描述

答案2

使用

    \multirow{-2}{*}{

让情节向上发展

在此处输入图片描述

相关内容