[texhax] determine remaining space
William F. Adams
wadams at atlis.com
Wed Sep 7 17:46:03 CEST 2005
On Sep 7, 2005, at 10:49 AM, Florian Knorn wrote:
> could anybody plz tell me a macro that returns the remaing space in the
> current text line ? like \remainingspace would contain the length like
> "3cm" if the remaining space to the end of the line is 3cm.
>
> now here is what i would like to be able to do with it.
>
> in my bibliography, i have a lot of urls. i would like to have them
> typeset like in the latex companion (2nd ed.). that is, the url is
> always the last entry in an bibliography item and right-aligned. it
> goes
> into a new line if the remaining space in the line is not enough to
> hold
> the entire url. if it is, the url stays in the same line.
>
> here is an example for that (where url fits)
>
> [1] Author 1, Title bla bla blabla blabla
> sept. 2004. urlurlurlurlurlurl
>
> and here where it doesn't
>
> [1] Author 1, Title bla bla blabla blabla
> some more bla, sept. 2004.
> urlurlurlurlurlurl
Instead of trying to work it out manually, set it up so that TeX will
place things where they should go automagically, say something like
this:
\documentclass{minimal}
\setlength{\textwidth}{2.375in}
\setlength{\parindent}{0pt}
\begin{document}
\parfillskip=0pt[1] Author 1, Title bla bla blabla blabla
sept. 2004. \hfill\allowbreak\strut\hfill
\strut\hfill\hbox{{\hfill urlurlurlurlurlurl}}
\parfillskip=0pt plus 1fil
and here where it doesn't
\parfillskip=0pt[1] Author 1, Title bla bla blabla blabla
some more bla, sept. 2004.
\hfill\allowbreak\strut\hfill
\strut\hfill\hbox{{\hfill urlurlurlurlurlurl}}
\parfillskip=0pt plus 1fil
This is an extra paragraph.
\end{document}
The key here is to restore \parfillskip after the paragraph ends.
William
--
William Adams, publishing specialist
voice - 717-731-6707 | Fax - 717-731-6708
www.atlis.com
More information about the texhax
mailing list