[texhax] determine remaining space
Florian Knorn
floz at gmx.de
Wed Sep 7 16:49:20 CEST 2005
hey there !
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
so i would like to have a macro \calcremainingspace so i could go within
an item:
@WHATEVER{bla,
AUTHOR = {...},
TITLE = {...},
NOTE = {\magicmacro{\url{http://theurl}}}
}
and in my stylesheet have defined
\newlength{urlwidth}
\newcommand{\magicmacro}[1]{%
\settowidth{\urlwidth}{#1}%
\ifthenelse{\remainingspace<\urlwidth}{%
\newline\hfill#1%
}{%
\hfill#1%
}%
}
anybody got an idead ? i'm sure it can't be that hard, but i just could
find anything of help.
thanks a million for yours however,
florian
More information about the texhax
mailing list