LaTeX has long been my main typesetting environment. This post has some handy dandy codes that I daily use.

Embedding a PDF File within

The following command is used in the document environment and embeds the specified PDF file.

  {} % title
  {./path-to/file.pdf} % file name
  {n} % n = page number + 1

To achieve a clean layout, remove headers and footers in file.pdf. Typically, outer PDF will carry out its headers and footers. This approach also provides a seamless integration.

Command in preamble:

	\phantomsection  \addcontentsline{toc}{section}{#1} % toc entry
	\whiledo{\value{pg}<#3}{ % page number +1
		\includepdf[pages=\thepg,scale=1,pagecommand={\pagestyle{fancy}}]{#2} % file name

Package dependencies in preamble:


Stamping Unique IDs

Often I print out documents with multiple copies. When it comes to exams, usually I scan the documents and do my grading electronically. Having unique IDs on every copy printed provides better file handling in this process.



% What is the starting number?

% How many exams do we need?

% Which is the input PDF file?

% This is to control the placement of the number.  
\textwidth  440pt
\textheight 590pt

% We use headers to output the serial number
\renewcommand{\headrulewidth}{0pt} % No header line
\renewcommand{\footrulewidth}{0pt} % No footer line

% Actual command to include the serial number
			% Some number padding - for up to 999 exams
			\ifnum\numberexam<100 0\fi%
			\ifnum\numberexam<10 0\fi%

% And here comes the single loop across all documents
% pagecommand by itself adds nothing, 
% but causes our new headers and footers to be printed