그림 옆에 테이블 놓기

그림 옆에 테이블 놓기

테이블을 만들었고 이 테이블 옆에 그림을 배치하고 싶습니다(첨부된 그림 참조).

  • 캡션은 둘 다 동일할 수 있습니다.
  • 테이블을 그림과 정렬하려면 행 사이의 공간을 늘려야 할 것입니다.
  • 테이블은 오른쪽이나 왼쪽에 배치할 수 있습니다.

내 코드를 남겨주세요:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[super]{natbib}
\usepackage{comment}
\usepackage{graphicx}
\usepackage{float}
\usepackage{hyperref}
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{caption}
\usepackage{adjustbox}
\usepackage{lipsum}
\usepackage{lscape}
\usepackage{multicol}
\usepackage{longtable}
\usepackage{chngcntr}
\counterwithin{figure}{section}
\counterwithin{table}{section}
\captionsetup[figure]{font=small,labelfont=bf}
\captionsetup[table]{font=small,labelfont=bf}
\usepackage[justification=centering]{caption}
\usepackage{eurosym}
\usepackage{mhchem}
\usepackage{relsize}
\usepackage[table, dvipsnames]{xcolor}
\renewcommand*\descriptionlabel[1]{\hspace\leftmargin$#1$}
\usepackage{enumitem}


\usepackage{array,ragged2e}
\newcolumntype{C}{>{\Centering\hspace{0pt}}p{0.1\textwidth}}
\usepackage[output-decimal-marker={,}]{siunitx}

\usepackage{booktabs, makecell, tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{M}{p{\dimexpr 0.25\textwidth-2\tabcolsep}}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}

\usepackage{longtable,array,ragged2e}
\newlength\mylen
\setlength\mylen{\dimexpr0.25\textwidth-1.5\tabcolsep-0.25\arrayrulewidth\relax}
\newcolumntype{Z}{>{\RaggedRight}p{\mylen}}

\usepackage[export]{adjustbox}   % <---
\usepackage{booktabs, tabularx}
\usepackage{array}
\usepackage{booktabs,tabularx}
\usepackage[export]{adjustbox}


\makeatletter
\newcommand*{\rom}[1]{\expandafter\@slowromancap\romannumeral #1@}
\makeatother
\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]}
\let\endchangemargin=\endlist 

\bibliographystyle{abbrvnat}
\setcitestyle{authoryear,open={(},close={)}}
\begin{document}

\begin{table}[h]
\resizebox{0.5\textwidth}{!}{%
\begin{tabular}{lcc}
\toprule
                    & Deterministic   & Stochastic \\
                    \midrule
Mean                & \euro430,96M        & \euro429,89M   \\
StDev               & \euro6,36M          & \euro5,44M     \\
n                   & 100             & 100        \\
\midrule
Best SP result      & \multicolumn{2}{c}{-\euro4,40M}  \\
Worst SP result     & \multicolumn{2}{c}{+\euro2,89M}  \\
Average performance & \multicolumn{2}{c}{-\euro1,08M}  \\
t-test              & \multicolumn{2}{c}{3,87E-10}\\
\hline
\end{tabular}%
}
\caption{Analysis of the comparison between the SP and the deterministic model.}
\label{tab:my-table}
\end{table}

\begin{figure}[H]
\centerline{\includegraphics[scale=0.26]{SD5.png}}
\begin{changemargin}{0.5cm}{0.5cm}
\vspace*{-1mm}
\caption{Analysis of the comparison between the SP and the deterministic model.}
\end{changemargin}
\label{fig}
\end{figure}
\vspace{-8mm}

여기에 이미지 설명을 입력하세요

답변1

여기에 이미지 설명을 입력하세요

  1. 내 관점은 이미지와 테이블을 tikzpicture. 테이블은 노드의 내용입니다..

  2. 나는 그림과 표를 "여백을 초과하지 않고" 나란히 놓도록 크기를 줄였습니다.

  3. 이미지를 제공해 주시지 않아서 환경에서 그림으로 만들었습니다 tikzpicture. 사용하시려면 코드를 변경하여 includegraphics노드의 컨텐츠에 사용하시면 됩니다. 일반적으로 가능하다면 include 대신 draw를 사용하세요!

  4. 아래 코드에서는 컴파일에 필요한 명령만 유지했습니다. 첫눈에 당신의 서문이 무거워 보입니다.

\documentclass[a4paper]{article}
\usepackage{eurosym}
\usepackage{booktabs, tabularx}

\usepackage{tikz}
\usetikzlibrary{calc, math}
\usepackage{lipsum}

\begin{document}

\lipsum[1]

\begin{table}[ht]
  \centering
  \tikzmath{real \r; \r=2.1; }
  \begin{tikzpicture}[scale=.9]
    \fill[green!30!black] (0, 0) circle (\r);
    \fill[gray!40] (0, 0) -- (\r, 0) arc (0:90:\r) -- cycle;
    \path (\r*.45, \r*.4)
    node[text width=8em, align=center, scale=.7] {Deterministic 25\%};
    \path (-\r*.45, -\r*.4)
    node[white, text width=6em, align=center, scale=.7] {\textbf{Stochastic 75\%}};
    
    \path (\r+.5, 0) node[right, scale=.9] {%
      \begin{tabular}{lcc}
        \toprule
        & Deterministic & Stochastic \\
        \midrule
        Mean                & \euro430,96M  & \euro429,89M   \\
        StDev               & \euro6,36M    & \euro5,44M     \\
        n                   & 100           & 100        \\
        \midrule
        Best SP result      & \multicolumn{2}{c}{-\euro 4,40M}  \\
        Worst SP result     & \multicolumn{2}{c}{+\euro 2,89M}  \\
        Average performance & \multicolumn{2}{c}{-\euro 1,08M}  \\
        t-test              & \multicolumn{2}{c}{3,87e-10}\\
        \hline
      \end{tabular}
    };
  \end{tikzpicture}
  \caption{Analysis of the comparison between the SP and the deterministic model.}
  \label{tab:my-table}
\end{table}

\lipsum[2-3]

\end{document}

답변2

나는 당신이 이것을 찾고 있다고 생각합니다 :

여기에 이미지 설명을 입력하세요

\documentclass{article}
\usepackage{eurosym}             % <---
\usepackage{caption}
\usepackage[export]{adjustbox}   % <---
\usepackage{booktabs, tabularx} 

\begin{document}
\begin{table}[ht]
    \begin{tabularx}{\linewidth}{@{}c X @{}}
    \includegraphics[width=0.3 \linewidth,valign=c]{example-image-duck}
    &   
        \begin{tabular}{lcc}
            \toprule
        & Deterministic   & Stochastic \\
                    \midrule
        Mean                & \euro430,96M  & \euro429,89M   \\
        StDev               & \euro6,36M    & \euro5,44M     \\
        n                   & 100           & 100        \\
        \midrule
        Best SP result      & \multicolumn{2}{c}{-\euro 4,40M}  \\
        Worst SP result     & \multicolumn{2}{c}{+\euro 2,89M}  \\
        Average performance & \multicolumn{2}{c}{-\euro 1,08M}  \\
        t-test              & \multicolumn{2}{c}{3,87E-10}\\
\hline
\end{tabular}
    \end{tabularx}
\caption{Analysis of the comparison between the SP and the deterministic model.}
\label{tab:my-table}
\end{table}
\end{document}

답변3

표 형식과 이미지가 동일한 수직 공간을 차지하도록 하려면 표 형식의 크기를 조정해야 합니다. 현재 버전에서는 공간의 절반 이상을 차지하기 때문입니다. (원칙적으로 이미지 크기를 조정하고 표 형식을 그대로 두라는 @Zarko의 답변에 동의합니다.)

다음은 테이블 크기를 조정하는 한 가지 방법입니다 resizebox.

\documentclass{article}
\usepackage{graphicx}
\usepackage{eurosym}
\usepackage{array}
\usepackage{booktabs,tabularx}
\usepackage[export]{adjustbox}

\begin{document}
text text text text text

\begin{table}[ht]
    \begin{tabularx}{\textwidth}{@{} X X @{}}
        \includegraphics[width=\linewidth,valign=c]{example-image-a}
        
        &
        \resizebox{\linewidth}{!}{
                \begin{tabular}{lcc}
                    \toprule
                    & Deterministic &    Stochastic    \\ \midrule
                    Mean                & \euro430,96M  &   \euro429,89M   \\
                    StDev               &  \euro6,36M   &    \euro5,44M    \\
                    n                   &      100      &       100        \\ \midrule
                    Best SP result      & \multicolumn{2}{c}{-\euro 4,40M} \\
                    Worst SP result     & \multicolumn{2}{c}{+\euro 2,89M} \\
                    Average performance & \multicolumn{2}{c}{-\euro 1,08M} \\
                    t-test              & \multicolumn{2}{c}{3,87e-10}     \\ \hline % or \bottomrule to keep in theme with toprule and midrule...
                \end{tabular}
        }
    \end{tabularx}
    \caption{Analysis of the comparison between the SP and the deterministic model.}
    \label{tab:my-table}
\end{table}

\end{document}

이는 전체 테이블을 가져와서 축소하므로 글꼴 크기와 규칙의 두께가 더 작아지고 잠재적으로 약간 이상해 보일 수 있습니다(이것이 제가 Zarko의 답변을 선호하는 이유입니다).

여기에 이미지 설명을 입력하세요

관련 정보