next up previous contents index
Next: Conditionals and Loops Up: C++ Basics Previous: Program Execution   Contents   Index

Raw output

More-or-less verbatim text can be printed to the output file. A single backslash is produced by a double backslash in the input file. Certain letters have special meanings when backslash-escaped, including ``\n'' (newline) and ``\t'' (TAB). Unlike LATEX, C++ does not require a space to separate an escape sequence from following text; the string ``\textwidth'' is read ``TABextwidth'' by the compiler.

As an application, a complete LATEX figure environment (with caption and label) can be produced by an ePiX file. Newlines must be added explicitly, and all printing statements must occur inside the call to main().

#include "epix.h"
using namespace ePiX;
using std::cout;      // C++'s output function

int main() 
{
  cout << "\\begin{figure}[hbt]\n";
  unitlength(...);    // picture, bounding_box, etc.
  begin();
  < ... ePiX commands ... >
  end();
  cout << "\\caption{A \\LaTeX\\ figure.}\n" // N.B. line con-
       << "\\label{fig:example}\n"           // tinues, no ";"
       << "\\end{figure}\n%%%%\n";           // LaTeX formatting
} // End of main()



Andrew D. Hwang 2004-09-04