\usepackage{graphicx}
\usepackage{multicol}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
\usepackage[export]{adjustbox}
\usepackage{wrapfig}
\begin{document}
\begin{table}[!htb]
\begin{minipage}{.5\linewidth}
\caption{Distribution Along Boundaries}
\begin{tabular}{c|c}
\toprule{}
Title1 & Title2\\
\hline \hline
D1 & 10\\
D2 & 6\\
D3 & 4\\
D4 & 2\\
\bottomrule
\label{table:distribution}
\end{tabular}
\linebreak
\caption{Mesh Across Domains}
\begin{tabular}{c|l|cc|c}
\toprule{}
{Title} & {Title} &\multicolumn{2}{c|}{Title} & {Title}\\
{} & {} & {X} & {Y} & {}\\
\hline \hline
1 & Free & 0. & 0 & 1\\
2 & Free & 0. & 0 & 4\\
3 & Free & 0. & 0 & 1\\
\bottomrule
\label{table:mesh}
\end{tabular}
\end{minipage}
\begin{minipage}{0.4\linewidth}
\begin{figure}[H]
\begin{flushright}
\includegraphics[width=1\columnwidth, right]{Figures/somefigure.png}
\caption{Caption}
\label{fig:somefig}
\end{flushright}
\end{figure}
\end{minipage}
\end{table}
\end{document}
答案1
表格和表格中的图像。对于表格使用tabularray
包,对于垂直中心使用图像adjustbox
包(也加载graphcx
包):
- 表格在表格列中左对齐的情况:
\documentclass[12pt]{article}
\usepackage[export]{adjustbox}
\usepackage[skip=0.33\baselineskip,
font=footnotesize, labelfont=bf]{caption}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{tabularray}
\UseTblrLibrary{booktabs, counter, varwidth}
\begin{document}
\begin{table}[htb]
\begin{tblr}{colspec = {@{} X[c] X[r] @{} },
measure = vbox
}
\begin{minipage}{\linewidth}%\centering
\captionsetup{singlelinecheck=off}
\caption{Distribution Along Boundaries}
\label{table:distribution}
\begin{tblr}{c|c}
\toprule
Title 1 & Title 2 \\
\midrule
D1 & 10 \\
D2 & 6 \\
D3 & 4 \\
D4 & 2 \\
\bottomrule
\end{tblr}
\bigskip
\caption{Mesh Across Domains}
\label{table:mesh}
\begin{tblr}{c|l|cc|c}
\toprule
Title & Title &\SetCell[c=2]{c} Title
& Title \\
& & X & Y & \\
\midrule
1 & Free & 0. & 0 & 1 \\
2 & Free & 0. & 0 & 4 \\
3 & Free & 0. & 0 & 1 \\
\bottomrule
\end{tblr}
\end{minipage}
& \includegraphics[width=0.8\linewidth,
valign=m]{example-image}
\captionof{figure}{Figure caption}
\label{fig:somefig}
\end{tblr}
\end{table}
\end{document}
- 表格以表格列为中心。对于此类设计,您需要:
- 删除 \captionsetup{singlelinecheck=off}
- 在上面的 MWE 中,在 Wit 这些更改之后添加
\centering
\command\begin{minipage}
,其编译结果为:
(红线表示文字边框)
答案2
如果您正在寻找这种布局
(1)\hfill
在两个小页之间添加,将图形推到右边距。
(2)用于\captionof{figure}{...}
在表格环境中添加图形标题。(需要包caption
)。
(3)将标签放在标题后。
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{caption} % for captionof <<<<
\usepackage{showframe}% ONLY to show the margins
\usepackage{booktabs}
\begin{document}
\begin{table}[!htb]
\begin{minipage}{.4\linewidth}
\caption{Distribution Along Boundaries} \label{table:distribution}
\begin{tabular}{c|c}
\toprule{}
Title1 & Title2\\
\hline \hline
D1 & 10\\
D2 & 6\\
D3 & 4\\
D4 & 2\\
\bottomrule
\end{tabular}
\bigskip
\caption{Mesh Across Domains}\label{table:mesh}
\begin{tabular}{c|l|cc|c}
\toprule{}
{Title} & {Title} &\multicolumn{2}{c|}{Title} & {Title}\\
{} & {} & {X} & {Y} & {}\\
\hline \hline
1 & Free & 0. & 0 & 1\\
2 & Free & 0. & 0 & 4\\
3 & Free & 0. & 0 & 1\\
\bottomrule
\end{tabular}
\end{minipage}
\hfill % added <<<<<<<<<<
\begin{minipage}{0.4\linewidth}
\includegraphics[width=1\columnwidth]{example-image}
\captionof{figure}{Figure caption} % changed <<<<<<<<<<<
\label{fig:somefig}
\end{minipage}
\end{table}
\end{document}
使用
\begin{table}[!htb]
\begin{minipage}{.59\linewidth}
\centering % added <<<<<<<<
\caption{Distribution Along Boundaries} \label{table:distribution}
产生更好看的布置