1

I have one issue with tables in harvard-thesis template version 0.4. I cannot set column width with column types such as p, m, b or even custom column types. If I set width to any of the columns, the column fills the entire text width irrespective of the value I use.

I am building with xelatex

enter image description here

Contents of file harvard-thesis.cls:

% https://github.com/TruePath/LaTeX-template-for-Harvard-dissertation/blob/master/harvard-thesis.cls
\NeedsTeXFormat{LaTeX2e} 
%################################################################################
%################################## harvard-thesis.cls starts here ##############
%################################################################################
\ProvidesClass{harvard-thesis}[2012/04/05 v0.4 Harvard University Thesis Class]  
\LoadClass[12pt, oneside, letterpaper]{book}
\RequirePackage{graphicx} 
\RequirePackage{hyperref} 
\RequirePackage{listings} 
\RequirePackage{afterpage}
 \hypersetup{   linktocpage,     colorlinks,   
citecolor=Crimson,     filecolor=black,     linkcolor=black,  
 urlcolor=Crimson, }
  \lstset{  float=h,     frame=single,  
basicstyle=\scriptsize,     breaklines=true, 
postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}
\hookrightarrow\space}} 
}
  \RequirePackage[title,titletoc]{appendix}
 \usepackage{lipsum}
  \usepackage{array,etoolbox}
 \preto\tabular{\setcounter{magicrownumbers}
{0}
}
 \newcounter{magicrownumbers}
 \newcommand\rownumber{\stepcounter{magicrownumbers}
\arabic{magicrownumbers}
}
  \usepackage{makecell}
  \usepackage[colorinlistoftodos, textwidth=4cm, shadow]{todonotes}
  \RequirePackage[centertags]{amsmath}
 \RequirePackage{amssymb}
 \RequirePackage[numbers,comma,sort&compress]{natbib}
 \RequirePackage[small, md, sc]{titlesec}
 \RequirePackage[tight,nice]{units}
 \RequirePackage{verbatim}
 \RequirePackage{textcomp}
  \RequirePackage{color}
 \definecolor{Crimson}
{rgb}
{0.6471, 0.1098, 0.1882}
  \RequirePackage{url}
 \RequirePackage[titles]{tocloft}
 \setcounter{tocdepth}
{1}
 \renewcommand{\cftchapfont}
{\normalsize \scshape}
  \renewcommand\bibname{References}
 \renewcommand\listfigurename{Listing of figures}
  \RequirePackage{pdfsync}
  \usepackage[closeFloats, noSeparatorLine]{fltpage}
 \RequirePackage{afterpage}
  \usepackage{float}
  \synctex=1 \RequirePackage{bibentry}
  \nobibliography*          \RequirePackage{lettrine}
 \RequirePackage[width=5in, letterpaper]{geometry}
  \RequirePackage{fancyhdr}
  \pagestyle{plain}
 \RequirePackage[palatino]{quotchap}
 \definecolor{chaptergrey}
{rgb}
{0.6,0,0}
 \RequirePackage{titling}
 \RequirePackage{setspace}
  \RequirePackage{booktabs,tabularx}
 \RequirePackage[labelfont={sf,bf,small}
,textfont={sf,small}
,justification=RaggedRight,margin=0pt, figurewithin=section, tablewithin=section]{caption}
 \onehalfspacing  \parindent 12pt \RequirePackage{mathspec}
  \RequirePackage{graphicx}
 \RequirePackage{enumitem}
 \usepackage[no-sscript]{xltxtra}
  \newcommand{\add}
[1]{\textcolor{orange}
{\ul{#1}
}
}
 \newcommand{\remove}
[1]{\textcolor{red}
{\textst{#1}
}
}
 \newcommand{\change}
[2]{\textcolor{red}
{\textst{#1}
}
\textcolor{green}
{\ul{#2}
}
}
 \newcommand{\hide}
[1]{}
  \RequirePackage{xunicode,soul}
  \def\degreeyear#1{\gdef\@degreeyear{#1}
}
 \def\degreemonth#1{\gdef\@degreemonth{#1}
}
 \def\degree#1{\gdef\@degree{#1}
}
 \def\advisor#1{\gdef\@advisor{#1}
}
 \def\department#1{\gdef\@department{#1}
}
 \def\field#1{\gdef\@field{#1}
}
 \def\university#1{\gdef\@university{#1}
}
 \def\universitycity#1{\gdef\@universitycity{#1}
}
 \def\universitystate#1{\gdef\@universitystate{#1}
}
   \renewcommand{\maketitle}
{   \singlespacing  \thispagestyle{empty}
    \vspace*{\fill}
 \vspace{150pt}
 \begin{center}
    \Huge \textcolor{Crimson}
{\textit{\thetitle}
}
 \normalsize \\ \sc \vspace{100pt}
    a dissertation presented \\ by\\    \theauthor\\ to\\ The \@department\\    \vspace{12pt}
    in partial fulfillment of the requirements\\    for the degree of\\ \@degree\\      in the subject of\\ \@field\\   \vspace{12pt}
    \@university\\ \@universitycity, \@universitystate\\    \@degreemonth\ \@degreeyear     \end{center}
 \vspace*{\fill}
 }
  \newcommand{\copyrightpage}
{   \newpage \thispagestyle{empty}
 \vspace*{\fill}
    \sc \noindent \copyright~\textit{\@degreeyear \hspace{3pt}
~- \theauthor}
 \\     \noindent All rights reserved.  \vspace*{\fill}
 \newpage \rm }
  \newcommand{\abstractpage}
{   \newpage    \pagenumbering{roman}
    \setcounter{page}
{3}
    \pagestyle{fancy}
    \lhead{Thesis advisor: \@advisor}
 \rhead{\@author}
    \renewcommand{\headrulewidth}
{0.0pt}
    \begin{center}
    \vspace*{1pt}
    \Large \textcolor{Crimson}
{\textit{\@title}
}
 \normalsize\\  \vspace*{15pt}
    \sc Abstract \\ \rm     \end{center}
    \doublespace    \input{frontmatter/abstract}
    \doublespace    \newpage \lhead{}
 \rhead{}
    \cfoot{\thepage}
    \onehalfspacing }
  \newcommand{\dedicationpage}
{   \pagestyle{fancy}
    \newpage \thispagestyle{fancy}
 \vspace*{\fill}
    \sc \noindent \input{frontmatter/dedication}
    \vspace*{\fill}
 \newpage \rm   }
  \newcommand{\authorlist}
{   \pagestyle{fancy}
    \newpage    \thispagestyle{fancy}
    \chapter*{Author List}
    \noindent \input{frontmatter/authorlist}
    \newpage \rm    }
  \newcommand{\acknowledgments}
{   \chapter*{Acknowledgments}
    \noindent   \input{frontmatter/thanks}
    \vspace*{\fill}
    \newpage    \setcounter{page}
{1}
    \pagenumbering{arabic}
}
     \providecommand\newthought[1]{    \addvspace{1.0\baselineskip plus 0.5ex minus 0.2ex}
    \noindent\textsc{#1}
}
     \usepackage{tikz}

%################################################################################
%################################## harvard-thesis.cls ends here ##############
%################################################################################

A sample document (must be compiled with XeLaTeX):

\documentclass{harvard-thesis}
  \begin{document}
 \pagestyle{plain}
  \begin{table}
 \scriptsize \caption{My table}
 \label{table1}
 \centering \begin{tabular*}
{\textwidth}
{|c|c|c|p{.3\textwidth}
|p{5cm}
|}
\hline 1 & 2 & 3 & 4 & consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis. Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum. Aliquam erat volutpat. Sed quis velit. Nulla facilisi. Nulla libero. Vivamus pharetra posuere sapien. Nam consectetuer. Sed aliquam, nunc eget euismod ullamcorper, lectus nunc ullamcorper orci, fermentum bibendum enim nibh eget ipsum. Donec porttitor ligula eu dolor. Maecenas vitae nulla consequat libero cursus venenatis. Nam magna enim, accumsan eu, blandit sed, blandit a, eros.\\ \hline \end{tabular*}
   \bigskip \caption{With \texttt{@{\string\extracolsep\{\string\fill\}
\}
}
}
}
 \begin{tabular*}
{\textwidth}
{@{\extracolsep{\fill}
}
 cccp{.3\textwidth}
p{5cm}
@{}
}
 \hline  1 & 2 & 3 & 4 & consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra   gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis. Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum. Aliquam erat volutpat. Sed quis velit. Nulla facilisi. \\  \hline  \end{tabular*}
  \end{table}
  \end{document}

The harvard-thesis.cls is originally from Jordan here https://github.com/suchow/Dissertate/blob/master/Dissertate.cls

but it seems to have been updated. I have included its contents in the code.

Mico
  • 506,678
gs_za
  • 113

1 Answers1

3

(Note: I've revised this answer completely after the OP posted the code of the thesis class in question.)

Thanks for posting the code of the thesis class you use. It turns out that this class file loads the pdfsync package, which is known to cause all kinds of problems. In my answer to an earlier posting entitled table badly too wide, I wrote the following:


The user guide of the pdfsync package suggests that

in case of severe conflicts with another package, try instead

\usepackage[novbox]{pdfsync}

Sure enough, adding the novbox option solves the immediate problem.

I honestly don't know enough about the pdfsync package to tell you if there's a better solution. Quoting from the "Bugs" section of the package's user guide:

pdfsync uses extremely [sensitive] code. You should not use pdfsync on final documents because it can change the layout rather significantly (different page/line breaks are the most obvious changes).

This isn't the most self-confident -- or confidence-inspiring -- statement, is it?


Returning to your document: There seems to be no reason for why your thesis class would load this package. I therefore strongly suggest that you delete the statement \RequirePackage{pdfsync}. If you delete the statement, the modified tabular* environment compiles fine.

Mico
  • 506,678
  • It does not work, I'll include the complete code below – gs_za Dec 07 '14 at 16:22
  • @George - After you posted the code of the file harvard-thesis.cls, I rewrote my answer completely. It turns out that the culprit, so to say, is the fact that the package pdfsync is being loaded. If you comment out (or delete) that instruction, the table is generated without further surprises. – Mico Dec 07 '14 at 17:47