3

Today,I typoset a book.

My code:

\documentclass[UTF8]{book}
\usepackage{geometry}
\usepackage{times} 
\usepackage[colorlinks,linkcolor=blue,anchorcolor=blue,citecolor=red,unicode]{hyperref} 
\geometry{left=2cm,right=2cm,top=2.8cm,bottom=2.5cm}

\begin{document}

   \tableofcontents
   \input{Preface}
   \input{Preface to the first edition}
   \input{Introduction}
   \input{chapter_1}
   \input{chapter_2}
   \input{chapter_3}
   \input{chapter_4}

\end{document}

However,the PDF file show Preface twice,not showing the chapter Preface to the first edition.So i wonder why and how to revise.

abc
  • 291
  • 1
    Did you use \chapter{Preface to the first edition} (or \chapter*{Preface to the first edition}) inside the corresponding file? – Gonzalo Medina Jan 19 '14 at 02:16
  • @Gonzalo Medina,Yes,I use the \chapter*{Preface to the first edition} and \chapter*{Preface} in two *.tex file ,repectively. – abc Jan 19 '14 at 02:25
  • 1
    @tangshuhao, Welcome to TeX.SX! 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. – Ch'en Meng Jan 19 '14 at 02:43
  • 1
    @Ch'en Meng,Ok ,I know. – abc Jan 19 '14 at 03:19
  • 2
    Don't use spaces in file names. Rename the file "Preface to the first edition" – Ulrike Fischer Jan 19 '14 at 08:22

1 Answers1

5

You shouldn't be \inputing them but \include. Further, it is better to use frontmatter, \mainmatter and \backmatter constructs. With these you don't have to use \chapter*{Preface to the first edition} but \chapter{Preface to the first edition} for chapters in frontmatter and backmatter. This will also take care of `proper page numbering scheme.

A sample code will be

\documentclass[UTF8]{book}
\usepackage{geometry}
\usepackage{newtxtext,newtxmath}   %% for times
\usepackage[colorlinks,linkcolor=blue,anchorcolor=blue,citecolor=red,unicode]{hyperref}
\geometry{left=2cm,right=2cm,top=2.8cm,bottom=2.5cm}

\begin{document}
 \frontmatter
   \tableofcontents
   \include{Preface}
   \include{Preface to the first edition}
 \mainmatter
   \include{Introduction}
   \include{chapter_1}
   \include{chapter_2}
   \include{chapter_3}
   \include{chapter_4}
 \backmatter  %% if any

\end{document}

\includeing has the advantage of \includeonly by which you can compile only one or two chapters. Ah, BTW, don't use times which is deprecated. Use newtxfonts instead say. Also, don't use file names with spaces like Preface to the first edition.

  • 1
    .thanks for your solution sincerely.However,it always show two preface in the contents.But when I put the \chapter{Preface to the first edition} on the main document it shows normally. – abc Jan 19 '14 at 03:18
  • 1
    Harish, my congratulations for 50k :-) – karlkoeller Jan 19 '14 at 08:16
  • 1
    @karlkoeller Thank you very much for your kindness. :) –  Jan 19 '14 at 09:49