我尝试制作以下表格,但做不到。另外,当地址太多时,表格就坏了。我很抱歉。也许我的问题很尴尬。谢谢。
\documentclass{article}
\usepackage{fancybox}
\usepackage{enumerate}
\usepackage{multirow}
\usepackage{tabulary}
\begin{document}
\newsavebox\mybox
\newenvironment{myfbox}{%
\begin{lrbox}{\mybox}%
\begin{minipage}{\dimexpr(\textwidth-2\fboxsep-2\fboxrule)}
}{%
\end{minipage}
\end{lrbox}%
\vskip10pt
\noindent
\fbox{\usebox\mybox}%
\vskip10pt
}
\newenvironment{myshadowbox}{%
\begin{lrbox}{\mybox}%
\begin{minipage}{\dimexpr(\textwidth-2\fboxsep-2\fboxrule-\shadowsize)}
}{%
\end{minipage}
\end{lrbox}%
\vskip10pt
\noindent
\shadowbox{\usebox\mybox}%
\vskip10pt
}
\begin{enumerate}
\item[] \fbox{\bf{1-Student information:}}
\vspace{-2mm}
\begin{myshadowbox}
\begin{tabular}{rlrlrl}
&&&&&\\
\vspace{2mm}
Name and Family:
&
\multicolumn{2}{ l}{
\textbf{
John
}
}
& &
{\small Student No:}
&
{\textbf{ 901901431} }\\
{\small Faculty:}
& &Science
& {\small Field:}
Pure mathematics
& {\small tendency:}
& {\textbf analysis}\\
\vspace{2mm}
{\small Year:}
&
{\textbf{2012}}
&
{\small Type :}
& Scholarships
&&\\
\vspace{2mm}
{\small Address:}
&
\multicolumn{3}{ l}{9 Royal Worcester Drive }
& {\small phone:}
&
{\small 011 44 1234 567890}\\
\vspace{2mm}
E-mail:&
\multicolumn{5}{l}{[email protected]}
\end{tabular}
\end{myshadowbox}
\end{enumerate}
\end{document}
答案1
据我所知,您放错了一些&
s。对于地址,您应该使用列p{<width>}
,可能还要加上以\raggedright
避免连字符。我认为没有办法tabularx
自动计算单元格的宽度\multicolumn{..}{p{..}}{..}
,因此您应该尝试使用固定宽度,甚至对所有单元格都使用固定宽度。
{ .. }
请注意,表格单元格本身会形成一个组,因此,如果您想更改字体大小等,则无需将内容换行。此外,您可以使用可选参数来\\
添加额外的垂直空间。不要使用\vspace
。
\documentclass{article}
\usepackage{array}
\begin{document}
\noindent
\fbox{%
\begin{tabular}{rlrlrl}
Name and Family: & \multicolumn{3}{l}{\textbf{John Doe Smith Stepherson}} & \small Student No: & \bfseries 901901431\\[2mm]
\small Faculty: & Science & {\small Field:} & Pure mathematics & \small tendency: & \bfseries analysis \\[2mm]
\small Year: & {\textbf{2012}} & \small Type of school: & Scholarships & & \\[2mm]
\small Address: & \multicolumn{3}{p{7cm}}{\raggedright 9 Royal Worcester Drive Somewhere in the wide wide world} & \small phone: & \small 011 44 1234 567890\\[2mm]
E-mail: & \multicolumn{5}{l}{[email protected]}\\
\end{tabular}}
\end{document}