Latex图片表格混排

我的文章中要求一幅图片和一个表格并列排在同一行上,

并且表格和图形都带有标题,在各自的正下方。模版将图形和表格都是居中的。我试着用了

minipage环境{figure环境+tabular环境},但是\caption{}只能在table下应用,总之图形和表

格都好处理,就是他们各自的标题总搞不定!

不知哪位高手遇到过这种情况,教我一下!万分感谢

【解决方案】

minipage 環境,裏面不要放 figure 和 table 環境,而是兩個 width 較小的 minipage 環境,\caption{...} 之前添加:
\makeatletter\def\@captype{figure}\makeatother % 在 figure 的 \caption 前
或者
\makeatletter\def\@captype{table}\makeatother % 在 table 的 \caption 前

例如:

 

image

实现代码如下:

\makeatletter\def\@captype{figure}\makeatother
\begin{minipage}{.45\textwidth}
\centering
\rule{3cm}{2cm}
\caption{The figure caption}
\end{minipage}
\makeatletter\def\@captype{table}\makeatother
\begin{minipage}{.45\textwidth}
\centering
\begin{tabular}{|c|c|c|c|c|}
  \hline
  % after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
  a & a & a & a & a \\
  a & a & a & a & a \\
  a & a & a & a & a \\
  a & a & a & a & a \\
  a & a & a & a & a \\
  \hline
\end{tabular}
\caption{The table title}
\end{minipage}

选自:http://bbs.ctex.org/viewthread.php?tid=37869

 

例子。

\begin{minipage}{\textwidth}

 

\begin{minipage}[t]{0.4\textwidth}

\centering

\resizebox{1.0in}{0.3in}{

\begin{tabular}{l}

\hline

\textbf{Algorithm 1}\quad Fast Mask Indexing\\

\hline

\textbf{Input:} 16-bit mask index $a$, value vector $v[]$;\\

\textbf{Output:} 1D coordinate $b$, $value$, $non\_zero$;\\

 

\textbf{do} $\tilde{a}$ = bit\_reverse($a$);\\

\textbf{do} $non\_zero$ = fast\_bit\_sum($a$);\\

\textbf{for }($i = 1, \ldots, non\_zero$ \textbf{and} $\tilde{a}\neq0$)\textbf{ do}\\

\quad $value=v[i]$;\\

\quad $b=$ low\_priority\_encoder($\tilde{a}$);\\

\quad $\tilde{a} = \tilde{a}$ \&\& $(\tilde{a}-1)$;\\

\textbf{end for}\\

\hline

\end{tabular}

}

\end{minipage}

 

\begin{minipage}[t]{0.4\textwidth}

\centering

\makeatletter\def\@captype{figure}\makeatother

% Requires \usepackage{graphicx}

\includegraphics[width=0.8in]{fast_index_module}\\

\caption{The architecture of FMI}

\end{minipage}

 

\end{minipage}

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
LaTeX中,引用图片表格需要使用`\label`命令为它们添加标签,然后使用`\ref`或`\cref`命令进行引用。 对于图片的引用,你可以在`\caption`命令后使用`\label`命令为图片添加标签。例如,你可以这样引用图片\[1\]: ``` \begin{figure}\[!ht\] \centering \includegraphics\[scale=0.8\]{22.png} \caption{图片标题} \label{fig:1} \end{figure} 在正文中,你可以使用`\ref`命令引用图片的标签,例如:根据图\ref{fig:1}所示... 对于表格的引用,你可以在`\caption`命令后使用`\label`命令为表格添加标签。例如,你可以这样引用表格\[2\]: ``` \begin{table}\[htbp\] \begin{center} \caption{表格标题} \label{tab:1} \begin{tabular}{cc} \hline year & tests \\ \hline 1962 & 178 \\ 1958 & 116 \\ 1968 & 79 \\ 1966 & 76 \\ 1961 & 71 \\ \hline \end{tabular} \end{center} \end{table} 在正文中,你可以使用`\ref`命令引用表格的标签,例如:根据表\ref{tab:1}所示... 需要注意的是,为了正确引用图片表格的标签,你可能需要多次编译LaTeX文档以生成正确的引用。 #### 引用[.reference_title] - *1* *2* [Latex表和图的显示、引用和并列](https://blog.csdn.net/m0_61344417/article/details/128677081)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [LaTeX 引用表格、照片、公式的时候自动添加 table,fig,equ](https://blog.csdn.net/Infinity_07/article/details/115250821)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值