我有以下代码:
\documentclass[a4paper,11pt]{article}
\usepackage[left=2.5cm, right=1.5cm, top=2.5cm, bottom=1.5cm]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{geometry}
\usepackage{multirow}
\renewcommand{\baselinestretch}{2}\normalsize
\centering
\begin{document}
\section{Data sheet}
Department of Mechanical Engineering\\
\flushleft
\textbf{1. Name} : Sandip R. More\\
\textbf{2. Registration No.} : ME12S037 \\
\textbf{3. Registered for} : MS By Research \\
\textbf{4. Specialization} : Machine Design\\
\textbf{5. Category} : Regular\\
\textbf{6. Guide} : Prof. P Chandramouli\\
\textbf{7. Date of joining} : 16 July 2012\\
\textbf{8. Date of Registration} : 16 July 2012\\
\textbf{9. Date of GTC Meeting} : 25 September 2013\\
\textbf{10. Area of Research} : Floating Raft Vibration Isolation\\
\textbf{11. Details of course work} :\\
\begin{table}[h]
\centering
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline \textbf{Sr No.}&\textbf{Course No.} &\textbf{Course title} &\textbf{Semester} &\textbf{core/Elective} &\textbf{Credit} &\textbf{Grade} \\
\hline 1& ID 6020 & Introduction to Research& Jul-Nov 2012 & Compulsory & 2 & P \\
\hline 2 & ME 7360 & Theory of Vibration & Jul-Nov 2012 & Core & 3 & B \\
\hline 3 & ME 6700 & Advanced Mechanics of Solid & Jul-Nov 2012 & Elective & 3 & B \\
\hline 4 & ME 6003 & Variational Principles in Mechanics & Jul-Nov 2012 & Elective & 3 & B \\
\hline 5 & ME 7840 & Signal processing of Mechanical Systems & Jul-Nov 2012 & Elective & 3 & B \\
\hline 6 & ME 7850 & Modal Analysis of Mechanical System & Jan-May 2013 & Core & 3 & A \\
\hline 7 & ME 6800 & Finite Element Analysis & Jan-May 2013 & Core & 3 & A \\
\hline 8 & ME 6000 & Computational methods in Engineering & July-Nov 2013 & Elective & 3 & Crediting \\
\hline 9 & ME7710 & Advanced Vibration and Acoustics & July-Nov 2013 & & 3 & Auditing \\
\hline
\end{tabular}
\end{table}
\end{document}
答案1
这是使用tabularx
的变体。我保留了booktabs
了埃格尔的回答,以及他的\addtolength{\tabcolsep}{-.7pt}
但是我已经删除了\splitcell
命令:这个想法是不必选择位置\\
并让TeX
段落构建算法完成这项工作。
\documentclass[a4paper,11pt]{article}
\usepackage[left=2cm, right=2cm, top=2.5cm, bottom=1.5cm,includefoot]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{tabularx}
\linespread{1.5}
\setlength{\parindent}{0pt}
\begin{document}\thispagestyle{empty}
\section{Data sheet}
Department of Mechanical Engineering
\textbf{1. Name}: Sandip R. More
\textbf{2. Registration No.}: ME12S037
\textbf{3. Registered for}: MS By Research
\textbf{4. Specialization}: Machine Design
\textbf{5. Category}: Regular
\textbf{6. Guide}: Prof. P Chandramouli
\textbf{7. Date of joining}: 16 July 2012
\textbf{8. Date of Registration}: 16 July 2012
\textbf{9. Date of GTC Meeting}: 25 September 2013
\textbf{10. Area of Research}: Floating Raft Vibration Isolation
\textbf{11. Details of course work}:
\begin{center}
\addtolength{\tabcolsep}{-.7pt}
\linespread{1}\selectfont
\begin{tabularx}{\linewidth}{cc>{\centering}Xcccc}
\toprule
&
\textbf{Course No.} &
\textbf{Course title} &
\textbf{Semester} &
\textbf{Core/Elective} &
\textbf{Credit} &
\textbf{Grade} \\
\midrule
1 & ID 6020 &
Introduction to Research &
Jul-Nov 2012 & Compulsory & 2 & P \\
\addlinespace[3pt]
2 & ME 7360 &
Theory of Vibration &
Jul-Nov 2012 & Core & 3 & B \\
\addlinespace[3pt]
3 & ME 6700 &
Advanced Mechanics of Solid &
Jul-Nov 2012 & Elective & 3 & B \\
\addlinespace[3pt]
4 & ME 6003 &
Variational Principles in Mechanics &
Jul-Nov 2012 & Elective & 3 & B \\
\addlinespace[3pt]
5 & ME 7840 &
Signal processing of Mechanical Systems &
Jul-Nov 2012 & Elective & 3 & B \\
\addlinespace[3pt]
6 & ME 7850 &
Modal Analysis of Mechanical System &
Jan-May 2013 & Core & 3 & A \\
\addlinespace[3pt]
7 & ME 6800 &
Finite Element Analysis &
Jan-May 2013 & Core & 3 & A \\
\addlinespace[3pt]
8 & ME 6000 &
Computational methods in Engineering &
July-Nov 2013 & Elective & 3 & Crediting \\
\addlinespace[3pt]
9 & ME7710 &
Advanced Vibration and Acoustics &
July-Nov 2013 & & 3 & Auditing \\
\bottomrule
\end{tabularx}
\end{center}
\end{document}
答案2
您的表格太宽,因此您需要减小其宽度;我建议将课程名称分成两行。
在展示代码之前需要注意一些事项。
\flushleft
不是文档中所述的命令;它存在,但不应使用。不过,\parindent
在这种情况下,设置为零似乎更好。不要这样做
\setlength{\baselineskip}{2\baselineskip}
,因为字体更改命令不会遵守它。最好使用\linespread{1.5}
前言中类似的命令。即使在这种情况下,也不要以 结束行
\\
;将其保留用于必须特别指示结束行的环境。您不需要将 a 括在用于浮动对象的
tabular
a 中。table
有了
booktabs
表格就更好了,以后再看。
为了压缩表格,我尝试了几次,每次都缩小\tabcolsep
一点。我还将边距改为相等,以便更好地显示结果,但这绝不是必要的。我还删除了第一列的标题,这只会增加宽度而不会承载任何信息。
\documentclass[a4paper,11pt]{article}
\usepackage[left=2cm, right=2cm, top=2.5cm, bottom=1.5cm,includefoot]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\newcommand{\splitcell}[2][c]{%
\linespread{1}\selectfont
\begin{tabular}{@{}#1@{}}\strut#2\strut\end{tabular}%
}
\linespread{1.5}
\setlength{\parindent}{0pt}
\begin{document}
\section{Data sheet}
Department of Mechanical Engineering
\textbf{1. Name}: Sandip R. More
\textbf{2. Registration No.}: ME12S037
\textbf{3. Registered for}: MS By Research
\textbf{4. Specialization}: Machine Design
\textbf{5. Category}: Regular
\textbf{6. Guide}: Prof. P Chandramouli
\textbf{7. Date of joining}: 16 July 2012
\textbf{8. Date of Registration}: 16 July 2012
\textbf{9. Date of GTC Meeting}: 25 September 2013
\textbf{10. Area of Research}: Floating Raft Vibration Isolation
\textbf{11. Details of course work}:
\begin{center}
\addtolength{\tabcolsep}{-.7pt}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
&
\textbf{Course No.} &
\textbf{Course title} &
\textbf{Semester} &
\textbf{Core/Elective} &
\textbf{Credit} &
\textbf{Grade} \\
\hline
1 & ID 6020 &
\splitcell{Introduction to\\ Research} &
Jul-Nov 2012 & Compulsory & 2 & P \\
\hline
2 & ME 7360 &
\splitcell{Theory of\\ Vibration} &
Jul-Nov 2012 & Core & 3 & B \\
\hline
3 & ME 6700 &
\splitcell{Advanced Mechanics\\ of Solid} &
Jul-Nov 2012 & Elective & 3 & B \\
\hline
4 & ME 6003 &
\splitcell{Variational Principles\\ in Mechanics} &
Jul-Nov 2012 & Elective & 3 & B \\
\hline
5 & ME 7840 &
\splitcell{Signal processing of\\ Mechanical Systems} &
Jul-Nov 2012 & Elective & 3 & B \\
\hline
6 & ME 7850 &
\splitcell{Modal Analysis of\\ Mechanical System} &
Jan-May 2013 & Core & 3 & A \\
\hline
7 & ME 6800 &
\splitcell{Finite Element\\ Analysis} &
Jan-May 2013 & Core & 3 & A \\
\hline
8 & ME 6000 &
\splitcell{Computational methods\\ in Engineering} &
July-Nov 2013 & Elective & 3 & Crediting \\
\hline
9 & ME7710 &
\splitcell{Advanced Vibration\\ and Acoustics} &
July-Nov 2013 & & 3 & Auditing \\
\hline
\end{tabular}
\end{center}
\end{document}
这是版本booktabs
\documentclass[a4paper,11pt]{article}
\usepackage[left=2cm, right=2cm, top=2.5cm, bottom=1.5cm,includefoot]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{booktabs}
\newcommand{\splitcell}[2][c]{%
\linespread{1}\selectfont
\begin{tabular}{@{}#1@{}}\strut#2\strut\end{tabular}%
}
\linespread{1.5}
\setlength{\parindent}{0pt}
\begin{document}
\section{Data sheet}
Department of Mechanical Engineering
\textbf{1. Name}: Sandip R. More
\textbf{2. Registration No.}: ME12S037
\textbf{3. Registered for}: MS By Research
\textbf{4. Specialization}: Machine Design
\textbf{5. Category}: Regular
\textbf{6. Guide}: Prof. P Chandramouli
\textbf{7. Date of joining}: 16 July 2012
\textbf{8. Date of Registration}: 16 July 2012
\textbf{9. Date of GTC Meeting}: 25 September 2013
\textbf{10. Area of Research}: Floating Raft Vibration Isolation
\textbf{11. Details of course work}:
\begin{center}
\addtolength{\tabcolsep}{-.7pt}
\begin{tabular}{ccccccc}
\toprule
&
\textbf{Course No.} &
\textbf{Course title} &
\textbf{Semester} &
\textbf{Core/Elective} &
\textbf{Credit} &
\textbf{Grade} \\
\midrule
1 & ID 6020 &
\splitcell{Introduction to\\ Research} &
Jul-Nov 2012 & Compulsory & 2 & P \\
\addlinespace[3pt]
2 & ME 7360 &
\splitcell{Theory of\\ Vibration} &
Jul-Nov 2012 & Core & 3 & B \\
\addlinespace[3pt]
3 & ME 6700 &
\splitcell{Advanced Mechanics\\ of Solid} &
Jul-Nov 2012 & Elective & 3 & B \\
\addlinespace[3pt]
4 & ME 6003 &
\splitcell{Variational Principles\\ in Mechanics} &
Jul-Nov 2012 & Elective & 3 & B \\
\addlinespace[3pt]
5 & ME 7840 &
\splitcell{Signal processing of\\ Mechanical Systems} &
Jul-Nov 2012 & Elective & 3 & B \\
\addlinespace[3pt]
6 & ME 7850 &
\splitcell{Modal Analysis of\\ Mechanical System} &
Jan-May 2013 & Core & 3 & A \\
\addlinespace[3pt]
7 & ME 6800 &
\splitcell{Finite Element\\ Analysis} &
Jan-May 2013 & Core & 3 & A \\
\addlinespace[3pt]
8 & ME 6000 &
\splitcell{Computational methods\\ in Engineering} &
July-Nov 2013 & Elective & 3 & Crediting \\
\addlinespace[3pt]
9 & ME7710 &
\splitcell{Advanced Vibration\\ and Acoustics} &
July-Nov 2013 & & 3 & Auditing \\
\bottomrule
\end{tabular}
\end{center}
\end{document}