请帮我解决我的代码。
我想将表格放在幻灯片的左侧,将图像放在幻灯片的右侧。
我希望表格宽度等于其中的文本。
这是我的代码:
\documentclass{beamer}
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{b{#1}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage{colortbl}
\usepackage{tcolorbox}
\usepackage{changepage}
\begin{document}
\begin{frame}{fIRST SLIDE}
\tiny
\setlength\tabcolsep{1pt}
% \adjustbox{max height=\dimexpr\textheight-5.5cm\relax,
% max width=\textwidth}
% T\resizebox{\textwidth}{!}{
\begin{tcolorbox}[tabularx={C|C},% <-- main change
boxrule=0.5pt, title = XXXXXXXXXXXXXXXXXXXXXXXXXXX]
Number of blades & XX \\ \hline
Rotor configuration & upwind \\ \hline
Rotor diameter (m)& YY \\ \hline
Rated power (kW) & ZZ \\ \hline
Hub height (m) & XX \\ \hline
Tower diameter top (m) & XX \\ \hline
Tower diameter base (m) & XX \\ \hline
Wind speed (m/s) & XX \\ \hline
Rotation rate (rpm) & XX \\ \hline
Blade pitch angle (\textsuperscript{0}) & XX \\ \hline
Yaw angle (\textsuperscript{0}) & XX
\end{tcolorbox}
\begin{figure}
\centering
\includegraphics[scale=0.25]{S809_WT.PNG}
\caption*{Figure 2.1: XXXXXX}
\end{figure}
\end{frame}
\end{document}
答案1
主要问题是您将图像放入figure
环境中。它告诉 LaTeX 将图像分开放置。我建议将框架分成两列。由于我没有您的图像,所以列的宽度只是一个猜测。
\documentclass{beamer}
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{b{#1}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage{colortbl}
\usepackage{tcolorbox}
\usepackage{changepage}
\begin{document}
\begin{frame}{fIRST SLIDE}
\begin{columns}
\begin{column}{0.6\textwidth}
\tiny
\setlength\tabcolsep{1pt}
\begin{tcolorbox}[tabularx={C|C},%
boxrule=0.5pt, title = XXXXXXXXXXXXXXXXXXXXXXXXXXX]
Number of blades & XX \\ \hline
Rotor configuration & upwind \\ \hline
Rotor diameter (m)& YY \\ \hline
Rated power (kW) & ZZ \\ \hline
Hub height (m) & XX \\ \hline
Tower diameter top (m) & XX \\ \hline
Tower diameter base (m) & XX \\ \hline
Wind speed (m/s) & XX \\ \hline
Rotation rate (rpm) & XX \\ \hline
Blade pitch angle ($^\circ$) & XX \\ \hline
Yaw angle ($^\circ$) & XX
\end{tcolorbox}
\end{column}
\begin{column}{0.4\textwidth}
\centering
\includegraphics[scale=0.25]{S809_WT.PNG}\\
{\tiny Figure 2.1: XXXXXX}
\end{column}
\end{columns}
\end{frame}
\end{document}
答案2
根据我对问题的理解,有一种替代方案,使用更大的字体,并自动调整第二个表格列的宽度:
\documentclass{beamer}
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{b{#1}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\usepackage{colortbl}
\usepackage[many]{tcolorbox}
% \usepackage{changepage}
\begin{document}
\begin{frame}{fIRST SLIDE}
\footnotesize
\begin{tabularx}{\textwidth}{cC}
\begin{tcolorbox}[
width=0.62\textwidth,
boxrule=0.5pt,
%
tabularx={R|c},%
title = XXXXXXXXXXXXXXXXXXXXXXXXXXX]
Number of blades & XX \\ \hline
Rotor configuration & upwind \\ \hline
Rotor diameter (m) & YY \\ \hline
Rated power (kW) & ZZ \\ \hline
Hub height (m) & XX \\ \hline
Tower diameter top (m) & XX \\ \hline
Tower diameter base (m) & XX \\ \hline
Wind speed (m/s) & XX \\ \hline
Rotation rate (rpm) & XX \\ \hline
Blade pitch angle ($^\circ$)& XX \\ \hline
Yaw angle ($^\circ$) & XX
\end{tcolorbox}
&
\includegraphics[width=\linewidth]{example-image}\newline
Figure 2.1: XXXXXX
\end{tabularx}
\end{frame}
\end{document}