这里的表格有问题。
我想|c|c|
工作,但工作却无法进行,而且我找不到获得我想要的东西的方法。
有人可以提供一些见解吗?也许可以提供页面链接(而不是tabularx
文档链接,因为它没有帮助)。
代码:
\documentclass[12pt]{article}
\usepackage{lipsum,wrapfig,graphicx,scrextend,sectsty,verbatim}
\usepackage{tikz,tkz-berge,amsmath,amsthm,amssymb,amsfonts}
\usepackage{tkz-graph,tabularx,adjustbox,enumerate,titlesec}
\usepackage[margin=1in]{geometry}
\usepackage[latin1]{inputenc}
%commands for the tree packages below
\usetikzlibrary{trees,fit,shapes,arrows,calc, patterns}
\begin{document}
\begin{table}
\centering
\begin{tabularx}{\linewidth}{ |c|X| }
\hline
\begin{tabular}[c]{@{}c@{}}
\begin{tikzpicture}[baseline=(current bounding box.center),scale=2]
\GraphInit[vstyle=Classic]
\SetUpVertex[Lpos=-90]
\tikzset{VertexStyle/.style = {shape=circle, fill=black, minimum size=3pt,inner sep=0pt}
}
\Vertex[x=0,y=0]{S$_0$}
\Vertex[x=1,y=-.5]{dS$_0$}
\Vertex[x=1,y=0]{mS$_0$}
\Vertex[x=1,y=.5]{uS$_0$}
\Vertex[x=0,y=-1]{t=0}
\Vertex[x=1,y=-1]{t=1}
\Edge[label = $\widetilde{p}_1$,color=red](S$_0$)(uS$_0$)
\Edges[label = $\widetilde{p}_2$,color=yellow](S$_0$,mS$_0$)
\Edges[label = $\widetilde{p}_3$,color=green](S$_0$,dS$_0$)
\Edges[label = $1+r$](t=0,t=1)
\end{tikzpicture}
\end{tabular}
&
\begin{enumerate}[I]
\item. $m < d < 1+r < u$
\item. $d < m < 1+r < u$
\item. $d < 1+r < m < u$
\item. $d < 1+r < u < m$
\end{enumerate}\\\hline
\end{tabularx}
\end{table}
\end{document}
答案1
我不确定期望的结果是什么样子。也许是这样的:
如果要将其用作|c|c|
表格的列声明,则必须在具有给定宽度的enumerate
框中使用环境,例如\parbox
或。或者您可以使用环境。此外,我还使用包来格式化枚举中的项目。minipage
varwidth
enumitem
\documentclass[12pt]{article}
\usepackage{tkz-graph}
\usepackage{varwidth}
\usepackage{enumitem}
\begin{document}
\begin{table}
\centering
\begin{tabular}{|c|c|}
\hline
\begin{tikzpicture}[baseline=(current bounding box.center),scale=2]
\GraphInit[vstyle=Classic]
\SetUpVertex[Lpos=-90]
\tikzset{VertexStyle/.style = {shape=circle, fill=black, minimum size=3pt,inner sep=0pt}}
\Vertex[x=0,y=0]{S$_0$}
\Vertex[x=1,y=-.5]{dS$_0$}
\Vertex[x=1,y=0]{mS$_0$}
\Vertex[x=1,y=.5]{uS$_0$}
\Vertex[x=0,y=-1]{t=0}
\Vertex[x=1,y=-1]{t=1}
\Edge[label = $\widetilde{p}_1$,color=red](S$_0$)(uS$_0$)
\Edges[label = $\widetilde{p}_2$,color=yellow](S$_0$,mS$_0$)
\Edges[label = $\widetilde{p}_3$,color=green](S$_0$,dS$_0$)
\Edges[label = $1+r$](t=0,t=1)
\path(current bounding box.north)--++(0,2pt);% enlarge the height of the picture
\end{tikzpicture}
&
\begin{varwidth}[c]{.6\linewidth}
\begin{enumerate}[label={\Roman*.}]
\item $m < d < 1+r < u$
\item $d < m < 1+r < u$
\item $d < 1+r < m < u$
\item $d < 1+r < u < m$
\end{enumerate}
\end{varwidth}\\
\hline
\end{tabular}
\end{table}
\end{document}
答案2
有两个因素会导致多余的空间:一个是 itemize 引入的初始空间,您可以通过\@minipagetrue
. 将其删除,另一个是 TikZ 图片中的基线选项。对于边框,请删除|
并\hline
s。
并且您不需要在 tabularx 环境中添加额外的表格。
这是一个手动调整的版本:
\documentclass[12pt]{article}
\usepackage{tkz-berge,amsmath,amsthm,amssymb,amsfonts,tkz-graph,tabularx,enumerate}
\usepackage[margin=1in]{geometry}
\usepackage[latin1]{inputenc}
%commands for the tree packages below
\usetikzlibrary{trees,fit,shapes,arrows,calc, patterns}
\begin{document}
\begin{table}
\centering
\begin{tabularx}{\linewidth}{ |c|>{\csname @minipagetrue\endcsname}X| }
\hline
\begin{tikzpicture}[scale=2,baseline={([yshift=1.5cm]current bounding box.center)}]
\GraphInit[vstyle=Classic]
\SetUpVertex[Lpos=-90]
\tikzset{VertexStyle/.style = {shape=circle, fill=black, minimum size=3pt,inner sep=0pt}}
\Vertex[x=0,y=0]{S$_0$}
\Vertex[x=1,y=-.5]{dS$_0$}
\Vertex[x=1,y=0]{mS$_0$}
\Vertex[x=1,y=.5]{uS$_0$}
\Vertex[x=0,y=-1]{t=0}
\Vertex[x=1,y=-1]{t=1}
\Edge[label = $\widetilde{p}_1$,color=red](S$_0$)(uS$_0$)
\Edges[label = $\widetilde{p}_2$,color=yellow](S$_0$,mS$_0$)
\Edges[label = $\widetilde{p}_3$,color=green](S$_0$,dS$_0$)
\Edges[label = $1+r$](t=0,t=1)
\end{tikzpicture}
& \begin{enumerate}[I]
\item. $m < d < 1+r < u$
\item. $d < m < 1+r < u$
\item. $d < 1+r < m < u$
\item. $d < 1+r < u < m$
\end{enumerate}\\\hline
\end{tabularx}
\end{table}
\end{document}
答案3
我以前也遇到过类似的问题。我的情况是,表格中有一些 Tikz 图形。我发现将 Tikz 图形作为 PDF 放置可以大大简化问题。也许您也可以将图形作为 PDF 放置。
下面是我所拥有的一个示例。
\documentclass[]{article}
\usepackage[a4paper]{geometry}
\usepackage{array}
\usepackage{amsmath}
\usepackage{upgreek}
\usepackage{caption}
\usepackage{graphicx}
\providecommand{\tabularnewline}{\\}
\captionsetup[table]{skip=10pt}
\setlength{\tabcolsep}{2pt}
\begin{document}
\begin{table}
\centering{}\caption{\label{tab:SummMass}A Summary}
\begin{tabular}{|>{\centering}m{6.2cm}|>{\centering}m{4cm}|>{\centering}m{4cm}|}
\hline
\smallskip{}
\textbf{Normalization Procedure} & \smallskip{}
\textbf{Generalized Mass} & \smallskip{}
\textbf{Effective Mass}\tabularnewline
\hline
\noindent \includegraphics[width=6cm]
{../Progress/EffMass/Paper/2017-05-20/figures/fig05a} &
$\begin{aligned}\bar{m} &
=\boldsymbol{\uppsi}^{\text{T}}\mathbf{M}\mathbf{\boldsymbol{\uppsi}}\\
& =\sum_{j=1}^{n}\left(\psi_{j}\right)^{2}m_{j}
\end{aligned}
$ & $
\begin{aligned}m_{i}^{\text{eff}} &
=\frac{\bar{m}}{\left(\psi_{i}\right)^{2}}\end{aligned}
$\tabularnewline
\hline
\includegraphics[width=6cm]{../Progress/EffMass/Paper/2017-05-20/figures/fig05b} &
$\begin{aligned}\bar{m}_{\text{D}} &
=\boldsymbol{\uppsi}_{\text{D}}^{\text{T}}\mathbf{M}\mathbf{\boldsymbol{\uppsi}}_{\text{D}}\\
& =\sum_{j=1}^{n}\left(\psi_{\text{D},j}\right)^{2}m_{j}
\end{aligned}
$ & $\begin{aligned}m_{i}^{\text{eff}} &
=\frac{\bar{m}_{\text{D}}}{\left(\psi_{\text{D},i}\right)^{2}}\end{aligned}
$\tabularnewline
\hline
\end{tabular}
\end{table}
\end{document}