我正在尝试将 Tikz 图片放入 tabularx 的单元格中。问题是它不适合我的单元格。以下是代码:
\documentclass[10pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{hhline}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\begin{document}
\begin{tabularx}{17cm}{|c|c|X|X|}
\hline
Solide & Expression & \multicolumn{2}{|c|}{Ordre de grandeur} \\ \hline\hline
Barre homogene & \multirow{3}{*}{$J_{\Delta} = \frac{1}{3}Ma^2$} & \multicolumn{2}{|c|}{Branche} \\ \cline{1-1}\cline{3-4}
\multirow{2}{*}{\begin{tikzpicture}
\draw [ultra thick] (-3,0)--(3,0) node [midway, below left] {$G$} ;
\draw (0,0) node{$\bullet$} ;
\draw [<->] (0,-0.5)--(3,-0.5) node [midway, below] {$a$} ;
\draw [dashed] (0,-1.5)--(0,1.5) node [near end, above right] {$\Delta$};
\end{tikzpicture}} & & $M=500g$ & $a=50cm$ \\ \cline{3-4}
& & \multicolumn{2}{|c|}{$4,2\times 10^{-2}$ $m^2.kg$} \\ \hline\hline
\end{tabularx}
\end{document}
提前感谢您提供的任何帮助。
答案1
我没有把它弄\multirow
大,而是把它旁边的行弄大。
\documentclass[10pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{hhline}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\newsavebox{\tempbox}
\begin{document}
\savebox{\tempbox}{%
\begin{tikzpicture}
\draw [ultra thick] (-3,0)--(3,0) node [midway, below left] {$G$} ;
\draw (0,0) node{$\bullet$} ;
\draw [<->] (0,-0.5)--(3,-0.5) node [midway, below] {$a$} ;
\draw [dashed] (0,-1.5)--(0,1.5) node [near end, above right] {$\Delta$};
\end{tikzpicture}}
\begin{tabularx}{17cm}{|c|c|X|X|}
\hline
Solide & Expression & \multicolumn{2}{|c|}{Ordre de grandeur} \\ \hline\hline
Barre homogene & \multirow{8}{*}{$J_{\Delta} = \frac{1}{3}Ma^2$} & \multicolumn{2}{|c|}{Branche} \\ \cline{1-1}\cline{3-4}
\multirow{2}{*}[4ex]{\usebox{\tempbox}} &\rule[\dimexpr 1ex-0.25\ht\tempbox]{0pt}{0.5\ht\tempbox} & $M=500g$ & $a=50cm$ \\ \cline{3-4}
& & \multicolumn{2}{|c|}{\rule[\dimexpr 1ex-0.25\ht\tempbox]{0pt}{0.5\ht\tempbox}$4,2\times 10^{-2}$ $m^2.kg$} \\ \hline\hline
\end{tabularx}
\end{document}