I am trying to create a macro which always places the text in its argument on the right side of the line and then the line should end.
For example:
Left-Text \mymacro{Right-Text}
should have text on the left and then when the text is done $\box$ should be placed on the right, but on the same line (as long as it fits).
I have tried
\newcommand{\mymacro}[1]{\hfill \mbox{#1}}
which works fine provided that Right-Text fits on the last line of Left-Text.
However, if Right-Text gets moved to a new line then it appears on the left side.
For example:
\documentclass{amsart}
\begin{document}
Doesn't work
Left Text 0123456789 Left Text 0123456789 Left Text 0123456789
\mymacro{Right Text}
Works
Left Text 0123456789 Left Text 0123456789 Left Text 0123456789 Left Text 0123456789
\mymacro{Right Text}
Works
Left Text 0123456789 Left Text 0123456789
\mymacro{Right Text}
\end{document}
\documentclass{...}and ending with\end{document}. – cfr Jul 06 '14 at 03:20