0

I want to create a line which exists horizontal blank spaces at start of the line. The effect like this: enter image description here

However, the line must have one character when use \hfill like this:

a\hfill Your-name-here

When I removed the a, the effect disappear and the code like this:

\hfill Your-name-here

I don't know how to solve the problem. Could you help me? Thanks!

3 Answers3

1

If you are at the beginning of the paragraph, then \hfill text works. But if you are after \hfil\break at the next line on the paragraph, then \hfill text does not work because \hfill is discardable item, it is removed after previous break. So, you have to do \hfil\break \null\hfill text. If you create a macro, then you can do \def\yourmacro{\leavevmode\null\hfill} and use \yourmacro text. This macro works in any context (in vertical mode, it starts horizontal mode first).

wipet
  • 74,238
0

Put an empty box in front of \hfill

\mbox{}\hfill Your-name-here
ZhiyuanLck
  • 4,516
0

Instead of \hfill, use \hspace{\fill}. I recommend to have a look at What is the difference between \hspace*{\fill} and \hfill?

However, from your question, I'm wondering if you don't just want right aligned text, do you?

\documentclass[]{article}
\begin{document}
\hspace{\fill}some text preceded by stretchable horizontal space
\begin{flushright}
some right aligned text
\end{flushright}
\end{document}

enter image description here