我正在使用报告格式mdframed
,需要在里面添加表格mdframed
。
\documentclass[11pt]{article}
\usepackage[table]{xcolor}
\usepackage{array,ragged2e}
\usepackage[pdftex]{graphicx}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\usepackage[margin=1cm]{geometry}
\usepackage[table]{xcolor}
\definecolor{lightgray}{gray}{0.9}
\begin{document}
\begin{mdframed}[roundcorner=10pt,leftmargin=1, rightmargin=1, linecolor=orange,outerlinewidth=1, innerleftmargin=15, innertopmargin=15,innerbottommargin=15]
\textbf{Detailed Genotype Table}
\leavevmode
\newline
\begin{table}[ht]
\newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}
\begin{center}
\rowcolors{1}{}{lightgray}
\begin{tabular}{|{\rule{0pt}{2cm}}c |P{2cm} | P{2cm} | P{2cm}|P{2cm} | P{2cm} | P{2cm}|P{2cm} | P{2cm} | P{2cm}|}
\rowcolor{orange} Gene &SNP &Odds Ratio &Genotype &Genotype &Genotypic Effect &Citations &Frequency\\
\hline
1 & 2.36 & 1.08 & -0.49 & -0.82 & -0.65 \\
2 & -0.68 & -1.13 & -0.42 & -0.72 & 1.51 \\
3 & -1.00 & 0.02 & -0.54 & 0.31 & 1.28 \\
4 & -0.99 & -0.54 & 0.97 & -1.12 & 0.59 \\
5 & -2.35 & -0.29 & -0.53 & 0.30 & -0.30 \\
6 & -0.10 & 0.06 & -0.85 & 0.10 & -0.60 \\
\hline
\end{tabular}
\end{center}
\end{table}
\leavevmode
\newline
\end{mdframed}
\leavevmode
\newline
\end{document}
但在上面的代码中,我无法获取 mdframed 中的表格。请问我错在哪里?任何示例都会对我有很大帮助。
谢谢
答案1
不要使用table
里面的浮动环境mdframed
;尝试框住浮动物体没有多大意义:
\documentclass[11pt]{article}
\usepackage[table]{xcolor}
\usepackage{array,ragged2e}
\usepackage[pdftex]{graphicx}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\usepackage[margin=1cm]{geometry}
\usepackage[table]{xcolor}
\definecolor{lightgray}{gray}{0.9}
\newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}
\begin{document}
\begin{mdframed}[roundcorner=10pt,leftmargin=1, rightmargin=1, linecolor=orange,outerlinewidth=1, innerleftmargin=15, innertopmargin=15,innerbottommargin=15]
\textbf{Detailed Genotype Table}
\centering
\rowcolors{1}{}{lightgray}
\begin{tabular}{|>{\rule{0pt}{2cm}}c |P{2cm} | P{2cm} | P{2cm}|P{2cm} | P{2cm} | P{2cm}|P{2cm} | P{2cm} | P{2cm}|}
\rowcolor{orange} Gene &SNP &Odds Ratio &Genotype &Genotype &Genotypic Effect &Citations &Frequency\\
\hline
1 & 2.36 & 1.08 & -0.49 & -0.82 & -0.65 \\
2 & -0.68 & -1.13 & -0.42 & -0.72 & 1.51 \\
3 & -1.00 & 0.02 & -0.54 & 0.31 & 1.28 \\
4 & -0.99 & -0.54 & 0.97 & -1.12 & 0.59 \\
5 & -2.35 & -0.29 & -0.53 & 0.30 & -0.30 \\
6 & -0.10 & 0.06 & -0.85 & 0.10 & -0.60 \\
\hline
\end{tabular}
\end{mdframed}
\end{document}
但是,如果您需要对象浮动,那么您可以反转嵌套顺序:
\documentclass[11pt]{article}
\usepackage[table]{xcolor}
\usepackage{array,ragged2e}
\usepackage[pdftex]{graphicx}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\usepackage[margin=1cm]{geometry}
\usepackage[table]{xcolor}
\definecolor{lightgray}{gray}{0.9}
\newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}
\begin{document}
\begin{table}
\begin{mdframed}[roundcorner=10pt,leftmargin=1, rightmargin=1, linecolor=orange,outerlinewidth=1, innerleftmargin=15, innertopmargin=15,innerbottommargin=15]
\centering
\textbf{Detailed Genotype Table}
\rowcolors{1}{}{lightgray}
\begin{tabular}{|>{\rule{0pt}{2cm}}c |P{2cm} | P{2cm} | P{2cm}|P{2cm} | P{2cm} | P{2cm}|P{2cm} | P{2cm} | P{2cm}|}
\rowcolor{orange} Gene &SNP &Odds Ratio &Genotype &Genotype &Genotypic Effect &Citations &Frequency\\
\hline
1 & 2.36 & 1.08 & -0.49 & -0.82 & -0.65 \\
2 & -0.68 & -1.13 & -0.42 & -0.72 & 1.51 \\
3 & -1.00 & 0.02 & -0.54 & 0.31 & 1.28 \\
4 & -0.99 & -0.54 & 0.97 & -1.12 & 0.59 \\
5 & -2.35 & -0.29 & -0.53 & 0.30 & -0.30 \\
6 & -0.10 & 0.06 & -0.85 & 0.10 & -0.60 \\
\hline
\end{tabular}
\end{mdframed}
\end{table}
\end{document}