-1

I am trying to write a question paper with Enrollment no written at the top right. But what is happening is that Enrollment number is coming on each page numbers at top right while I want it to come only on the first page. I attempted to resolve this problem but not able to do so.

Thank you very much

Here is my Latex code

\documentclass[12pt]{article}
\usepackage{times}
\usepackage{amsthm,amsmath,amssymb,amsmath,amsfonts,graphicx,fancyhdr,algorithmic,longtable,listings,color,epsfig}
\usepackage{mathptmx}% times is deprecated
\usepackage[scaled=.90]{helvet}
\usepackage{courier}
\usepackage{epstopdf}
\usepackage{calligra}
\usepackage{csquotes}
\usepackage{xcolor}
\usepackage{color}
%\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{geometry}

\usepackage{background}
\usepackage{lipsum}
\SetBgContents{\textbf{Enrollment No}..........}
\SetBgColor{black}
\SetBgScale{1}
\SetBgAngle{0}
\SetBgPosition{current page.north east}
\SetBgHshift{-4cm}
\SetBgVshift{-2cm}



\DeclareMathAlphabet{\mathcalligra}{T1}{calligra}{m}{n}
\textheight 9.1 truein \hoffset -1.3cm \voffset -5mm \textwidth 6.7 truein
\evensidemargin 1cm

\def\demo{%
  \par\topsep6pt plus6pt
  \trivlist
  \item[\hskip\labelsep\it Proof.]\ignorespaces}
\def\enddemo{\qed \endtrivlist}
\expandafter\let\csname enddemo*\endcsname=\enddemo

\def\qedsymbol{\ifmmode\bgroup\else$\bgroup\aftergroup$\fi
  \vcenter{\hrule\hbox{\vrule
height.6em\kern.6em\vrule}\hrule}\egroup}
\def\qed{\ifmmode\else\unskip\nobreak\fi\quad\qedsymbol}

\newtheorem{Theorem}{Theorem}[section]
%\newtheorem{Proof}{Proof}[section]
\newtheorem{prop}{Proposition}[section]
\newtheorem{Definition}{Definition}[section]
\newtheorem{Proposition}{Proposition}[section]
\newtheorem{Lemma}{Lemma}[section]
\newtheorem{Corollary}{Corollary}
\newtheorem{Example}{Example}[section]
\newtheorem{Remark}{Remark}[section]
\newtheorem{Note}{Note}[section]
 \newtheorem{tab}{Table}%[section]
\newcommand{\R} {\mbox {$ I\!\!R $}}
\newcommand{\bea}{\begin{eqnarray}}
\newcommand{\eea}{\end{eqnarray}}
\newcommand{\be}{\begin{equation}}
\newcommand{\ee}{\end{equation}}
\newcommand{\nn}{\nonumber}
\newcommand{\nii}{\noindent}
\newcommand{\bee}{\begin{eqnarray*}}
\newcommand{\eee}{\end{eqnarray*}}
\def\A{{\cal{A}}}
\def\B{{\cal{B}}}
\def\C{{\cal{C}}}
\def\R{{\cal{R}}}
\def\Q{{\cal{Q}}}
\def\N{{\cal{N}}}
\def\P{{\cal{P}}}
\font\bigbf=cmbx12 \font\ssr=cmss8 \font\sst=cmtt8 \font\tt=cmtt10
\font\ssb=cmbx8 \font\srm=cmr8 \font\ssi=cmti8 \font\sar=cmss12
\font\srs=cmr6

\newcommand{\ra}[1]{\mathrm{rank}\left({#1}\right)}  % rank
\newcommand{\ind}[1]{\mathrm{ind}({#1})}  % index
\newcommand{\cond}[1]{\mathrm{cond}({#1})}  % condition number
\newcommand{\tr}[1]{\mathrm{Tr}({#1})}  % trag
\newcommand{\oo}[1]{{\overline{\overline{#1}}}}
\newcommand{\ov}[1]{{\overline{#1}}}
\newcommand{\e}{\mathcal{E}}
\newcommand{\Eff}{\mathrm{Eff}}
\newcommand{\Ind}{\mathrm{Ind}}
\newcommand{\Sp}{\mathrm{Sp}}
\newcommand{\Ef}{\mathrm{Ef}}
%\newcommand{\dim}{\mathrm{dim}}
\newcommand{\ef}{\mathrm{ef}}
\newcommand{\col}{\mathrm{col}}
\newcommand{\row}{\mathrm{row}}
\renewcommand{\O}{\mathcal{O}}
\renewcommand{\widehat}[1]{#1}
\def\Re{\,{\rm{Re}}\,}
\def\Im{\,{\rm{Im}}\,}
\pagenumbering{gobble}

\font\bigbf=cmbx12 \font\ssr=cmss8 \font\ssv=cmss10 \font\sst=cmtt8
\font\ssb=cmbx8 \font\srm=cmr8 \font\ssi=cmti8 \font\bigbf=cmbx12
\font\ssr=cmss8 \font\ssv=cmss10 \font\sst=cmtt8 \font\ssb=cmbx8
\font\srm=cmr8 \font\ssi=cmti8


\renewcommand{\theequation}{\thesection.\arabic{equation}}





\begin{document}




\begin{center}
\large{\textbf{Any university\\End Semester Examination, December 2016\\ M.Sc. \\MAT - Analysis}}
\end{center}

\begin{tabular}{p{11cm}r}
\textbf{Max. Marks: 100} &   \textbf{Duration:3 hours}
\end{tabular}\\
\begin{center}
{\textbf{Part A}\\ Answer all questions. Each question carries $6$ marks. }
\end{center}
\begin{enumerate}
\item Some questions.

\begin{center}
{\textbf{Part B}\\ Answer all questions. Each question carries $8$ marks. }
\end{center}
\item Questions
\end{enumerate}

\begin{center}
\text{End}\end{center}

\end{document}
  • 3
    Thank you for posting a working example! At the same time, much of your code does not seem to be relevant to the question you're asking here. Please limit the example to only the code required for your issue to appear. You can have a look at this guide for how to prune your code for this purpose. – Martin Schröder Nov 8 '16 at 21:25
  • @MartinSchröder Thank you for your suggestions. – srijan Nov 9 '16 at 7:41
5

Please use the \usepackage[pages=some,placement=top]{background} or \usepackage[some,top]{background} option with the background package and \BgThispage option in the first page as follows for your required output:

\documentclass[12pt]{article}
\usepackage{times,lipsum}
\usepackage{amsthm,amsmath,amssymb,amsfonts,graphicx,fancyhdr,algorithmic,longtable,listings,color,epsfig}
\usepackage{mathptmx}% times is deprecated
\usepackage[scaled=.90]{helvet}
\usepackage{courier}
\usepackage{epstopdf}
\usepackage{calligra}
\usepackage{csquotes}
\usepackage{xcolor}
\usepackage{color}
%\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{geometry}

\usepackage[pages=some,placement=top]{background}

\SetBgContents{\textbf{Enrollment No}..........}

\SetBgColor{black}
\SetBgScale{1}
\SetBgAngle{0}
\SetBgPosition{current page.north east}
\SetBgHshift{-4cm}
\SetBgVshift{-2cm}

\begin{document}

\BgThispage

\begin{center}
\large{\textbf{Any university\\End Semester Examination, December 2016\\ M.Sc. \\MAT - Analysis}}
\end{center}

\begin{tabular}{p{11cm}r}
\textbf{Max. Marks: 100} &   \textbf{Duration:3 hours}
\end{tabular}\\
\begin{center}
{\textbf{Part A}\\ Answer all questions. Each question carries $6$ marks. }
\end{center}
\begin{enumerate}
\item Some questions.

\begin{center}
{\textbf{Part B}\\ Answer all questions. Each question carries $8$ marks. }
\end{center}
\item Questions
\end{enumerate}

\begin{center}
\text{End}\end{center}
\lipsum[1-7]
\end{document}

Output:

enter image description here enter image description here

| improve this answer | |
  • Thank you for the help. But I am getting this Latex error: Unknown option pages = some for package background. – srijan Nov 4 '16 at 10:55
  • Try this then: \usepackage[some,top]{background} – Ambika Vanchinathan Nov 4 '16 at 10:57
  • Thank you very very much for your great help. I am grateful to you. I am from IIT Kharagpur. Thanks again. – srijan Nov 4 '16 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.