# How to make right alignment the marks of exam questions?

I would like to prepare a question paper in latex in which the credential point of question should be right alignment. I have tried with article document class, but not working.

MWE:

\documentclass[11pt,a4paper]{article}
\usepackage{amssymb,amsmath,fullpage}
\usepackage{enumerate}
\usepackage{multicol}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\footrulewidth}{0pt}
\newcommand{\marksA}[1]{\hfill\makebox[0pt][l]{~#1}}
\begin{document}
\thispagestyle{empty}
\pagenumbering{roman}
\begin{flushright}
\it\small   H(I)-Mathematics-H-I(Module-I)
\end{flushright}

\begin{center}
\textbf{\Large 2017}\\[2ex]
\textbf{MATHEMATICS - HONOURS}\\
\textbf{\small First Paper}\\
\textbf{(Module-I)}\\
\textbf{\small  Full Marks - 50}\\[2ex]
{   \it The figures in the margin indicate full marks.}\\
{\it    Candidates are requested to  give their answer in their own words as far as practicable}
\end{center}

% FRONT Matter

\pagenumbering{arabic}

\begin{center}
\bf     Group - A\\
(Marks - 35)
\end{center}
\begin{center}
\end{center}
\begin{enumerate}

\item  State the First Principle of Mathematical Induction". Using this principle show htat $10^{n+1}+10^n+1$ is divisible by $3$ for all positive integers $n$.  \marksA{$1+4$}
\item
\begin{enumerate}
\item Prove that $\phi(3n)=3\phi(n)$ if and only if $3$ is a divisor of $n$.   \marksA{$3$}

\begin{multicols}{2}
\begin{enumerate}[(i)]
\item $\{x^2:x\in [0,1]\}$
\item $\{ 5+\sqrt{7}t:t\in \mathbb{Q} \}$
\item $(0,1])\cap (\mathbb{R}\setminus \mathbb{Q})$
\item $\{\frac{1}{x}:x\in(0,\infty) \}$
\end{enumerate}
\end{multicols}

\item item
\end{enumerate}
\end{enumerate}
\end{document}.


Output:

• Do you want the marks in the margin? – egreg Apr 8 at 16:34
• @egreg Yes I want marks in the margin. – BSFU Apr 8 at 16:36
• Try \newcommand{\marksA}[1]{\marginpar{\hfill #1}} BTW, your code crashes on my machine. – John Kormylo Apr 8 at 17:03

This is an application of the “Bourbaki trick”, plus measuring the widths and storing the largest in the aux file.

This requires two runs of LaTeX to stabilize.

\documentclass[11pt,a4paper]{article}
\usepackage{amssymb,amsmath,fullpage}
\usepackage{enumerate}
\usepackage{multicol}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\renewcommand{\footrulewidth}{0pt}

\newlength{\finalwidth}
\newlength{\tempwidthA}
\newlength{\tempwidthB}
\makeatletter
\AtEndDocument{\write\@auxout{\global\finalwidth=\the\tempwidthB}}
\makeatother
\newcommand{\marksA}[1]{% the Bourbaki trick
\ifdim\tempwidthA>\tempwidthB \global\tempwidthB=\tempwidthA\fi
\unskip
{\nobreak\hfill\penalty50\hskip1em\null\nobreak
\parfillskip=0pt \finalhyphendemerits=0 \par}%
}

\begin{document}
\thispagestyle{empty}
\pagenumbering{roman}

\begin{flushright}
\itshape H(I)-Mathematics-H-I(Module-I)
\end{flushright}

\begin{center}
\textbf{\Large 2017}\\[2ex]
\textbf{MATHEMATICS -- HONOURS}\\
\textbf{First Paper}\\
\textbf{(Module-I)}\\
\textbf{Full Marks -- 50}\\[2ex]
{\itshape The figures in the margin indicate full marks.}\\
{\itshape Candidates are requested to give their answer in their
own words as far as practicable}
\end{center}

% FRONT Matter

\pagenumbering{arabic}

\begin{center}
\textbf{Group -- A}\\
(Marks - 35)
\end{center}
\begin{center}
\end{center}
\begin{enumerate}

\item State the First Principle of Mathematical Induction''.
Using this principle show that $10^{n+1}+10^n+1$ is divisible
by $3$ for all positive integers $n$.  \marksA{$1+4$}
\item
\begin{enumerate}
\item Prove that $\phi(3n)=3\phi(n)$ if and only if $3$ is a divisor of $n$.\marksA{$3$}

\begin{multicols}{2}
\begin{enumerate}[(i)]
\item $\{x^2:x\in [0,1]\}$
\item $\{ 5+\sqrt{7}t:t\in \mathbb{Q} \}$
\item $(0,1])\cap (\mathbb{R}\setminus \mathbb{Q})$
\item $\{\frac{1}{x}:x\in(0,\infty) \}$
\end{enumerate}
\end{multicols}

\item item
\end{enumerate}
\end{enumerate}
\end{document}


I made some changes: I find that \small adds nothing, just strange changes in the font size. Also \it should never be used in new documents: it has been obsolete and deprecated for more than 25 years. Closing quotes should be input as '' (two apostrophes) rather than ".