\raggedbottom       %reduce underfull \vbox

\usepackage{titlesec, titletoc}
%change the part format in book 
\titleformat{\part}[frame]{\normalfont\huge\bfseries}{\partname\ \thepart }{20pt}{\Huge\centering}
%change the part format in table of contents
[0pt]{\sffamily\bfseries\huge\protect\addvspace{25pt}\titlerule\addvspace{1.5ex}}%remove rule if you like
{\hfill\contentspage}%replaced with {} if don't want page number for parts
[\addvspace{0.7ex}\titlerule\addvspace{10pt}]%remove rule if you like

%change the chapter format in table of contents
{\chaptertitlename\ \thecontentslabel~}{}

%change the appendix name from chapter to appendix
%force paragraph newline

%insert figures

%improve the interface for defining floating objects such as figures and tables

%customize page layout
\usepackage[a4paper, left=3cm, right=3cm]{geometry}


%page headers and footers   left,right,odd,even

\title{\Huge C++ \\\qquad\textcolor{RedOrange}{Primer}}
\author{\textbf{Stanley B.Lippman} \and \textbf{Jos\'ee Lajoie} \and \textbf{Barbara E.Moo}}

\renewcommand{\epigraphflush}{center} %center
\setlength\epigraphrule{0pt} %cancel the line between words and person name

                columns=flexible, %cancel monospced characters
                showstringspaces=false %not show space

%change the width of lrbox( lrbox is the environment form of \sbox, which is similar to \mbox)

%change baseline of pictures(eg: valign)

%declare \graybox to be a bin for saving box

%note environment
    { \par\addvspace{\baselineskip}
    { \end{varwidth}

%tips enviroment       
    { \par\addvspace{\baselineskip}

%warning enviroment    
    { \par\addvspace{\baselineskip}

%complement enviroment
      { \par\addvspace{\baselineskip}
        {\color{Black}   \vspace{0.5ex} \hrule height 0.1ex} \vspace{0.5ex}}

%type­sets text in mul­ti­ple columns (up to a max­i­mum of 10)

%revise\@endpart macro

%use \cmidrule \toprule

% add mini-ta­bles-of-con­tents (mini­tocs) at the be­gin­ning of ev­ery chap­ter, part or sec­tion.

%set two text form

    \tcolorbox[enhanced,left=2pt,right=2pt,title=\large{\textbf{\GetExerciseName~\thesubsection}},% append .\GetExerciseProperty{counter} to count inside subsection,
        colback=white,colframe=black,colbacktitle=gray!50,coltitle=black,sharp corners=all]%
    exercise-name=Exercise Section,

  {\refstepcounter{myquestion}\textbf{Exercise \thechapter.\themyquestion :}}{}

%initialize minitoc



\chapter{Getting Started}
    \section{Writing a Simple C++ Program}
        \subsection{Compiling and Executing Our Program}
Explain whether the following program fragment is legal.
std::cout << "The sum of " << v1;
<< " and " << v2;
<< " is " << v1 + v2 << std::endl;
If the program is legal, what does it do? If the program is not legal, why
not? How would you fix it?
    \section{A First Look at Input/Output}
    \section{A Word about Comments}
    \section{Flow of Control}
        \subsection{The while Statement}
        \subsection{The for Statement}
        \subsection{Reading an Unknown Number of Inputs}
        \subsection{The if Statement}
    \section{Introducing Classes}   
        \subsection{The Sales\_item Class}
        \subsection{A First Look at Member Functions}
    \section{The Bookstore Program}
    \section*{Chapter Summary} \markright{Chapter Summary} \addcontentsline{toc}{section}{Chapter Summary}
    \section*{Defined Terms} \markright{Defined Terms} \addcontentsline{toc}{section}{Defined Terms}

\part{The Basics}
\chapter{Variables and Basic Types}
    \section{Primitive Built-in Types}
        \subsection{Arithmetic Types}
        \subsection{Type Conversions}

\chapter{The Library}
    \section{Library Names and Headers}


\chapter{New features in C++11}


enter image description here

  • The problem is a tab in front of \end{lstlisting}. Remove that and it won't appear.
    – TeXnician
    Commented Sep 20, 2017 at 15:08
  • To amplify TeXnician's comment, the symbol ^^I is the way TeX denotes an ASCII tab character. See TeXbook, p.45, 343-344, 351, 368, 370, & 391. Commented Sep 20, 2017 at 15:11
  • @TeXnician interesting, can you tell me the reason about it.
    – K.Robert
    Commented Sep 20, 2017 at 15:11
  • 1
    On TeXbook, page 45, "TEX has a standard way to refer to the invisible characters of ASCII: Code 0 can be typed as the sequence of three characters ^^@, code 1 can be typed ^^A, and so on up to code 31, which is ^^_ (see Appendix C). If the character following ^^ has an internal code between 64 and 127, TEX subtracts 64 from the code; if the code is between 0 and 63, TEX adds 64. Hence code 127 can be typed ^^?, and the dangerous bend sign can be obtained by saying {\manual^^?}..." Commented Sep 20, 2017 at 15:13
  • "...However, you must change the category code of character 127 before using it, since this character ordinarily has category 15 (invalid); say, e.g., \catcode‘\^^?=12. The ^^ notation is different from \char, because ^^ combinations are like single characters; for example, it would not be permissible to say \catcode‘\char127, but ^^ symbols can even be used as letters within control words." Commented Sep 20, 2017 at 15:13

1 Answer 1


TeXnician properly identified the problem by noting the \end{lstlisting} was tabbed in, and advised to remove it. There are several lessons here.

  1. In verbatim environments, indenting with spaces and/or tabs is captured as data by the environment, unlike typical TeX, where indented space is ignored.

  2. A verbatim tab is displayed as ^^I, according to TeX convention. Why is this? Those of us old enough to remember dealing exclusively in ASCII recall that a tab (ASCII 9) is equivalent to a CTL-I, where I is the 9th letter of the alphabet (and ^ was historically used to denote the CTL key; thus my generation immediately recognizes ^I as the keyboard entry CTL-I).

It seems obvious that Knuth wanted to preserve that notion for those already familiar with that widely used at the time syntax. As to how he implemented it in TeX, he describes the neat technique on page 45 of the TeXbook, of using ^^ to permit direct access to all 128 ASCII codes.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .