I am trying to create a command for right alignment of text. The text must be kept on the same line if it fits on the line, else it must flow to the next line but must keep the alignment (right aligned). Currently I can do these with two separate commands, like:
\renewcommand{\marks}[1]{\ \newline\hfill\textbf{[#1\hphantom{a}marks]}}
or
\renewcommand{\marks}[1]{\ \hfill\textbf{[#1\hphantom{a}marks]}}
However, I am unable to combine them. That is,
- if I use the first command then it puts a new line even if there is space on the same line.
- if I use the second command then it puts the
marks
towards the left on the next line if space is unavailable on the same line.
Thanks.