I was wondering why elastic lengths like \fill
seem to work only under certain conditions.
For instance if I write
A \hspace{\fill} B
I get A left aligned, B right aligned as wanted. If however I write
A \rule{\fill}{1mm} B
is results in a zero width rule. Just to be sure that I didn't just mix up parameters I also tried \rule{1mm}{\fill}
. With fixed widths like \linewidth
or 2cm
\rule
works fine.
Similiarily when I write
\begin{minipage}{\fill}
Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test.
\end{minipage}
I get output that looks like
Test.
Test.
Test.
Test.
Test.
...
i.e. presumably again zero width.
It is easy enough to find some solution for each specific problem on Google, usually coming down to "write these lines into your file" or "import that package". I want to understand why there is anything to solve to begin with so I can come up with my own solutions in the future.
Some minimal compileable example for demonstrating some cases:
\documentclass{article}
\parindent=0cm
\parskip=\fill % use of fill for vertical spacing.
\begin{document}
A \hspace{\fill} B
C \rule{2cm}{1mm} D
E \rule{\fill}{1mm} F
\begin{minipage}{\textwidth}
Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test.
Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test.
\end{minipage}
\begin{minipage}{\fill}
Test. Test. Test. Test. Test. Test.
\end{minipage}
\end{document}