[Tex/LaTex] Writing a thesis in Lyx using a Latex Template – What am I doing wrong

bibtexlyxtemplatesthesis

I'm looking to write my thesis in Lyx as I'm impressed with all the document handling features.

I have found, what is called, a Latex template for my university's thesis here: http://www.cs.columbia.edu/mice/c/d.php?d=109

The template contains a set of .tex, .bst. and .sty files as well as a simple Makefile. Running make does produce a nice pdf that looks exactly like a bare bones thesis would.

Now how can I get Lyx to play nice with all of this? For one, I don't see anything for dealing with Makefiles.

Am I shooting for the moon?

Best Answer

I think the following should cover most things. If anything is missing or appears wrong, please let me know.

File organisation

Place named.sty and named.bst in the same folder as your .lyx file.

Document class options

Go to Document --> Settings --> Document class, choose Report from the list of classes, and add

11pt,openright,twoside,letterpaper

to the Custom options. (The template actually had openright,oneside, but the former has no effect with the latter, so I switched to twoside. I also removed the onecolumn option.)

enter image description here

Preamble

Paste the below code in Document --> Settings --> LaTeX preamble. Notes:

  • You should of course modify the first three lines, adding your title, name and year.

  • I removed the epsfig package, don't think it's normally used these days, and LyX loads graphicx (which is recommended for dealing with external images) anyway.

  • I removed the dvipdfm and letterpaper options to hyperref. You'll probably compile with pdfLaTeX, making the first of these wrong. The latter is not used.

  • I moved some stuff from the document to the preamble, including the definition of a pagestyle (myplain, I switched name from plain) and \renewcommand\contentsname{Table of Contents}.

    \newcommand{\thesistitle}{Thesis title}
    \newcommand{\thesisauthor}{Author's name}
    \newcommand{\thesisyear}{20XX}
    
    %%%
    %%% Packages
    %%%
    \usepackage{named}
    \usepackage{fancyhdr}
    \usepackage{afterpage}
    
    %
    % We use the hyperref package and customize it for optimal PDF 
    %
    \usepackage[
       pdftitle={\thesistitle},
       pdfauthor={\thesisauthor},
       pdfpagemode={UseOutlines},
       bookmarks,
       bookmarksopen=true,
       pdfstartview={FitH},
       bookmarksnumbered=true]{hyperref}
    
    %%%
    %%% Margins
    %%%
    \paperwidth=8.5in
    \paperheight=11in
    
    % 1in + hoffset + oddsidemargin + textwidth + marginparsep + marginparwidth
    % For PhD at Columbia we have single side theses and 1.5in left margin
    % The settings below leave 1.5 inch margin at the left and 1 inch at the right 
    % for US Letter paper
    \setlength{\hoffset}{0.0in}
    \setlength{\oddsidemargin}{.5in}
    \setlength{\textwidth}{6in}
    \setlength{\evensidemargin}{0mm}
    
    % 1in + voffset + topmargin + headheight + headsep + textheight + footskip 
    % For PhD thesis we also need an extra inch at the bottom
    % 1inch = 72 pt
    \setlength{\voffset}{0.0in}
    \setlength{\topmargin}{.0in}
    \setlength{\headheight}{14pt}
    \setlength{\headsep}{22pt}
    \setlength{\textheight}{8.5in}
    \setlength{\footskip}{0pt}
    
    %%%
    %%% Spacing
    %%%
    \newcommand{\singlespace}{\renewcommand{\baselinestretch}{1.15} \small \normalsize}
    \newcommand{\oneandhalfspace}{\renewcommand{\baselinestretch}{1.3} \small \normalsize}
    \newcommand{\doublespace}{\renewcommand{\baselinestretch}{1.5} \small \normalsize}
    \newcommand{\normalspace}{\doublespace}
    \footnotesep=1\baselineskip
    
    %%%
    %%% Counters depth
    %%%
    \setcounter{secnumdepth}{3}
    \setcounter{tocdepth}{3}
    
    %%%
    %%% Title page.
    %%%
    \newcommand{\thesistitlepage}{
        \normalspace
        \thispagestyle{empty}
        \begin{center}
            \textbf{\LARGE \thesistitle} \\[1cm]
            \textbf{\LARGE \thesisauthor} \\[8cm]
            Submitted in partial fulfillment of the \\
            requirements for the degree \\
            of Doctor of Philosophy \\
            in the Graduate School of Arts and Sciences \\[4cm]
            \textbf{\Large COLUMBIA UNIVERSITY} \\[5mm]
            \thesisyear
        \end{center}
        \clearpage
    }
    
    %%%
    %%% Copyright page.
    %%%
    \newcommand{\thesiscopyrightpage}{
        \thispagestyle{empty}
        \strut \vfill
        \begin{center}
          \copyright \thesisyear \\
          \thesisauthor \\
          All Rights Reserved
        \end{center}
        \cleardoublepage
    }
    
    %%%
    %%% Abstract page.
    %%%
    \newcommand{\thesisabstract}{
        \thispagestyle{empty}
        \begin{center}
        \textbf{\LARGE ABSTRACT} \\[1cm]
         \textbf{\LARGE \thesistitle} \\[1cm]
         \textbf{\LARGE \thesisauthor} \\[1cm]
        \end{center}
        \input{abstract}
        \cleardoublepage
    }
    
    %%%
    %%% Miscellaneous
    %%%
    \newcommand{\draft}{
        \renewcommand{\normalspace}{\singlespace}
        \normalspace
        \chapter*{Draft. Version \today}
    \clearpage }
    
    
    \renewcommand{\contentsname}{Table of Contents}
    
    
    % We change the pagestyle 
    \fancypagestyle{myplain} {%
    \fancyhf{}
    \fancyhead[LE,RO]{\thepage}
    \fancyhead[RE,LO]{\itshape \leftmark}
    \renewcommand{\headrulewidth}{0pt}
    }
    

In the document

  1. Start by adding an ERT (Ctrl + L) with

    % For the first pages we do not have numbering
    
    \pagestyle{empty}
    
    \thesistitlepage
    \thesiscopyrightpage
    \thesisabstract
    % In the "roman-numbered" section of the thesis, we have numbers at the bottom % and we have to reduce the textheight of the text to make space for the number
    \pagenumbering{roman}
    \pagestyle{plain}
    
    \setlength{\footskip}{0.5in}
    
  2. After the ERT, add the table of contents, list of figures and list of tables via the Insert --> List/ToC menu.

  3. Add an unnumbered chapter, call it Acknowledgements and write those here.

    (This is not exactly the same as in the template.)

  4. If you want the dedication page, do the following:

    i. Do Insert --> Formatting --> Clear double page

    ii. Insert --> Formatting --> Vertical space. Choose VFill, check the box for Protect.

    iii. Write your dedication.

    iv. Add a second VFill, as step i).

    v. Insert --> Formatting --> Clear Double page

  5. Add a new ERT with

    \pagenumbering{arabic}
    
    % In the "arabic" section of the thesis, we do not have numbers at  the
    % bottom and we want to use the full length of the page to avoid vbox 
    % underfulls. We use the fancyheaders package to adapt the headers 
    % according to the  Columbia requirements. 
    
    \setlength{\textheight}{8.5in}
    \setlength{\footskip}{0in}
    
    \pagestyle{myplain}
    
  6. Write all your content.

Bibliography

Where the bibliography should be, do Insert --> List/ToC --> BibTeX bibliography. Select your .bib file, and from the Style drop down menu, choose named.

Complete example

The code below is actually a .lyx file, you can copy the text, save it as something.lyx and open it in LyX. It is generated by LyX 2.0.6, as LyX 2.1 isn't in Ubuntu's repositories yet, and I haven't bothered updating manually. (I never really use LyX anyway.)

#LyX 2.0 created this file. For more info see http://www.lyx.org/
\lyxformat 413
\begin_document
\begin_header
\textclass report
\begin_preamble
\newcommand{\thesistitle}{Thesis title}
\newcommand{\thesisauthor}{Author's name}
\newcommand{\thesisyear}{20XX}

%%%
%%% Packages
%%%
\usepackage{amsmath}
\usepackage{named}
\usepackage{fancyhdr}
\usepackage{afterpage}

%
% We use the hyperref package and customize it for optimal PDF 
%
\usepackage[pdftitle={\thesistitle},pdfauthor={\thesisauthor},pdfpagemode={UseOutlines},letterpaper,bookmarks,bookmarksopen=true,pdfstartview={FitH},bookmarksnumbered=true,]{hyperref}

%%%
%%% Margins
%%%
\paperwidth=8.5in
\paperheight=11in

% 1in + hoffset + oddsidemargin + textwidth + marginparsep + marginparwidth
% For PhD at Columbia we have single side theses and 1.5in left margin
% The settings below leave 1.5 inch margin at the left and 1 inch at the right 
% for US Letter paper
\setlength{\hoffset}{0.0in}
\setlength{\oddsidemargin}{.5in}
\setlength{\textwidth}{6in}
\setlength{\evensidemargin}{0mm}

% 1in + voffset + topmargin + headheight + headsep + textheight + footskip 
% For PhD thesis we also need an extra inch at the bottom
% 1inch = 72 pt
\setlength{\voffset}{0.0in}
\setlength{\topmargin}{.0in}
\setlength{\headheight}{14pt}
\setlength{\headsep}{22pt}
\setlength{\textheight}{8.5in}
\setlength{\footskip}{0pt}

%%%
%%% Spacing
%%%
\newcommand{\singlespace}{\renewcommand{\baselinestretch}{1.15} \small \normalsize}
\newcommand{\oneandhalfspace}{\renewcommand{\baselinestretch}{1.3} \small \normalsize}
\newcommand{\doublespace}{\renewcommand{\baselinestretch}{1.5} \small \normalsize}
\newcommand{\normalspace}{\doublespace}
\footnotesep=1\baselineskip

%%%
%%% Counters depth
%%%
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

%%%
%%% Title page.
%%%
\newcommand{\thesistitlepage}{
    \normalspace
    \thispagestyle{empty}
    \begin{center}
        \textbf{\LARGE \thesistitle} \\[1cm]
        \textbf{\LARGE \thesisauthor} \\[8cm]
        Submitted in partial fulfillment of the \\
        requirements for the degree \\
        of Doctor of Philosophy \\
        in the Graduate School of Arts and Sciences \\[4cm]
        \textbf{\Large COLUMBIA UNIVERSITY} \\[5mm]
        \thesisyear
    \end{center}
    \clearpage
}

%%%
%%% Copyright page.
%%%
\newcommand{\thesiscopyrightpage}{
    \thispagestyle{empty}
    \strut \vfill
    \begin{center}
      \copyright \thesisyear \\
      \thesisauthor \\
      All Rights Reserved
    \end{center}
    \cleardoublepage
}

%%%
%%% Abstract page.
%%%
\newcommand{\thesisabstract}{
    \thispagestyle{empty}
    \begin{center}
    \textbf{\LARGE ABSTRACT} \\[1cm]
     \textbf{\LARGE \thesistitle} \\[1cm]
     \textbf{\LARGE \thesisauthor} \\[1cm]
    \end{center}
    \input{abstract}
    \cleardoublepage
}

%%%
%%% Miscellaneous
%%%
\newcommand{\draft}{
    \renewcommand{\normalspace}{\singlespace}
    \normalspace
    \chapter*{Draft. Version \today}
\clearpage }


\renewcommand{\contentsname}{Table of Contents}
\setcounter{tocdepth}{2}


% We change the pagestyle 
\fancypagestyle{myplain} {%
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE,LO]{\itshape \leftmark}
\renewcommand{\headrulewidth}{0pt}
}
\end_preamble
\options 11pt,openright,twoside,letterpaper,onecolumn
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100

\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_amsmath 1
\use_esint 1
\use_mhchem 1
\use_mathdots 1
\cite_engine basic
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout

% For the first pages we do not have numbering
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout


\backslash
pagestyle{empty}
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout


\backslash
thesistitlepage
\end_layout

\begin_layout Plain Layout


\backslash
thesiscopyrightpage
\end_layout

\begin_layout Plain Layout


\backslash
thesisabstract
\end_layout

\begin_layout Plain Layout

% In the "roman-numbered" section of the thesis, we have numbers at the
 bottom % and we have to reduce the textheight of the text to make space
 for the number
\end_layout

\begin_layout Plain Layout


\backslash
pagenumbering{roman}
\end_layout

\begin_layout Plain Layout


\backslash
pagestyle{plain}
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout


\backslash
setlength{
\backslash
footskip}{0.5in}
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset CommandInset toc
LatexCommand tableofcontents

\end_inset


\end_layout

\begin_layout Standard
\begin_inset FloatList figure

\end_inset


\end_layout

\begin_layout Standard
\begin_inset FloatList table

\end_inset


\end_layout

\begin_layout Chapter*
Acknowledgements
\end_layout

\begin_layout Standard
So long and thanks for all the fish.
\end_layout

\begin_layout Standard
\begin_inset Newpage cleardoublepage
\end_inset


\end_layout

\begin_layout Standard
\begin_inset VSpace vfill*
\end_inset


\end_layout

\begin_layout Standard
\align center
Dedication
\end_layout

\begin_layout Standard
\begin_inset VSpace vfill*
\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage cleardoublepage
\end_inset


\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout


\backslash
pagenumbering{arabic}
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

% In the "arabic" section of the thesis, we do not have numbers at  the
\end_layout

\begin_layout Plain Layout

% bottom and we want to use the full length of the page to avoid vbox 
\end_layout

\begin_layout Plain Layout

% underfulls.
 We use the fancyheaders package to adapt the headers 
\end_layout

\begin_layout Plain Layout

% according to the  Columbia requirements.

\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout


\backslash
setlength{
\backslash
textheight}{8.5in}
\end_layout

\begin_layout Plain Layout


\backslash
setlength{
\backslash
footskip}{0in}
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout


\backslash
pagestyle{plain}
\end_layout

\end_inset


\end_layout

\begin_layout Chapter
Intro
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "chap:intro"

\end_inset


\end_layout

\begin_layout Standard
This is about stuff.
\end_layout

\begin_layout Part
Stuff
\end_layout

\begin_layout Chapter
Something
\end_layout

\begin_layout Standard
Etc.
\begin_inset CommandInset citation
LatexCommand cite
key "Grosz_and_Sidner_1986"

\end_inset


\end_layout

\begin_layout Part
Appendices
\end_layout

\begin_layout Standard
\begin_inset CommandInset bibtex
LatexCommand bibtex
bibfiles "refs"
options "named"

\end_inset


\end_layout

\end_body
\end_document