I'm writing an exam and using a \marks macro with \strut and \hfill to show the marks available for each question right-aligned, bold and in square brackets. But sometimes it doesn't put it on the right! In the MWE output, 1 and 4 are correct, 2 and 3 are wrong. In the source, 1 and 3 have no space before the \marks, 2 and 4 do.
I'm using \strut thanks to the answer here.
\documentclass[11pt]{article}
\usepackage{fullpage}
\renewcommand{\marks}[1]{\strut\hfill\textbf{[#1]}}
\begin{document}
Sample Exam!
\begin{enumerate}
\item xx3 x xxxxxx x x x x xxx x x x x x x xx x x x x x xxxx x x x xx x xxxxxxx xxx x x x x xx\marks{5}
\item xx3 x xxxxxx x x x x xxx x x x x x x xx x x x x x xxxx x x x xx x xxxxxxx xxx x x x x xx \marks{5}
\item xxx4 x xxxxxx x x x x xxx x x x x x x xx x x x x x xxxx x x x xx x xxxxxxx xxx x x x x xx\marks{5}
\item xxx4 x xxxxxx x x x x xxx x x x x x x xx x x x x x xxxx x x x xx x xxxxxxx xxx x x x x xx \marks{5}
\end{enumerate}
\end{document}



examclass? It's a great tool to produce exams in LaTeX. – Vincent Feb 23 '20 at 13:28