1

I've had a hard time incorporating my C++ code into a document which was formatted using the AMS book template.

%-----------------------------------------------------------------------
% Beginning of chapter.tex
%-----------------------------------------------------------------------
%
%  This is a sample file for use with AMS-LaTeX.  It provides an example
%  of how to set up a file for a book to be typeset with AMS-LaTeX.
%
%  This is the driver file.  Separate chapters should be included at
%  the end of this file.
%
%  ***** DO NOT USE THIS FILE AS A STARTER FOR YOUR BOOK. *****
%  Follow the guidelines in the file chapter.template.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass{amsbook}

\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage{xcolor}
\lstset{
    frame=tb, % draw a frame at the top and bottom of the code block
    tabsize=4, % tab space width
    showstringspaces=false, % don't mark spaces in strings
    numbers=left, % display line numbers on the left
    commentstyle=\color{green}, % comment color
    keywordstyle=\color{blue}, % keyword color
    stringstyle=\color{red} % string color
}

%\includeonly{preface, chap1, array, biblio,index}

\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{lemma}[theorem]{Lemma}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{xca}[theorem]{Exercise}

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}

\numberwithin{section}{chapter}
\numberwithin{equation}{chapter}



%    Absolute value notation
\newcommand{\abs}[1]{\lvert#1\rvert}

\newcommand{\bcode}{\begin{lstlisting}[language=C++,breaklines]}
\newcommand{\ecode}{\end{lstlisting}}



%    Blank box placeholder for figures (to avoid requiring any
%    particular graphics capabilities for printing this document).
\newcommand{\blankbox}[2]{%
  \parbox{\columnwidth}{\centering
%    Set fboxsep to 0 so that the actual size of the box will match the
%    given measurements more closely.
    \setlength{\fboxsep}{0pt}%
    \fbox{\raisebox{0pt}[#2]{\hspace{#1}}}%
 }%
}


\begin{document}
\frontmatter
\title{My LaTeX Experiment}


%    Address of record for the research reported here
%\address{Department of Mathematics, Louisiana State University, Baton Rouge, Louisiana 70803}
%    Current address
%\curraddr{Department of Mathematics and Statistics, Case Western Reserve University, Cleveland, Ohio 43403}
%\email{xyz@math.university.edu}
%    \thanks will become a 1st page footnote.
%\thanks{The first author was supported in part by NSF Grant \#000000.}

%    Information for second author
%\author{Author Two}
%\address{Mathematical Research Section, School of Mathematical Sciences,
%Australian National University, Canberra ACT 2601, Australia}
%\email{two@maths.univ.edu.au}

\date{July 2, 1991}
\subjclass[2010]{Primary 54C40, 14E20;\\Secondary 46E25, 20C20}
\keywords{\texttt{amsbook}, AMS-\LaTeX}

\begin{abstract}
This document is a sample prepared to illustrate the use of the
American Mathematical Society's \LaTeX{} document class
\texttt{amsbook} and publication-specific variants of that class.
\end{abstract}

\maketitle

\setcounter{page}{4}
\tableofcontents

\include{preface}

\mainmatter

\include{chap1}
\include{array}


\backmatter
\include{biblio}
\include{index}
\end{document}

It gave me the errors. Can any one share some working code with me?

Thank you very much for your time.

13
  • 2
    Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – jub0bs
    Jan 31, 2016 at 20:51
  • 3
    If I complete that example by adding \begin{document}\end{document} then it runs through latex without error, so any error you get is in code you haven't shown and gives an error message that you have not shown. That makes it hard to help. Jan 31, 2016 at 21:00
  • @Jubos. Thanks, I added the complete code of the driver file. The source files can be downloaded here ams.org/publications/authors/books/monopackages
    – Newbie
    Feb 1, 2016 at 1:33
  • @DavidCarlisle It gave me errors like "Overfull \hbox...". Any hints?
    – Newbie
    Feb 2, 2016 at 21:43
  • 4
    I'm voting to close this question as off-topic because the question was referred to ams tech-support, where failure to provide sufficient information made it impossible to answer May 8, 2016 at 18:48

0

Browse other questions tagged or ask your own question.