[texhax] Entering horizontal lines between items
Uwe Lück
uwe.lueck at web.de
Thu Jan 10 14:02:56 CET 2013
Am Mittwoch, den 09.01.2013, 14:43 -0500 schrieb Jerry:
> Assume this example:
>
> NAME _______________________________________ PHONE: ____________
>
> PROPERTY OWNER: ____________________________ PHONE: ____________
>
> This is probably a bad example. However, assume I want the PHONE to
> begin in 5in. from the left margin. I can manually get it all worked
> out; however, when I insert the second line, I have to figure the
> horizontal line length.
>
> Essentially, what I want to accomplish is saying:
>
> Put TEXT here, then underline from the end of that text 5 inches from
> the left margin and then place THIS text, then underline to right
> margin. Not every line has every item in the same location and some
> lines have 3 items on them.
>
> A formula like: {lmargin + distance to indent - length of text} would
> work I assume. I have no idea how to code anything like that. Is there a
> package that offers that ability?
The most interesting question for me still is what you want to get.
"This" and "that" are very difficult to understand when there are
at least four different things, I even don't understand "text" when
there at least two text pieces. Also "item" is not clear, it doesn't
mean more than "thing". I also don't understand indent
One might focus on the case where you say there are "2 items" and
deal with the other case when the first one has been clarified.
NAME ______________________________________ PHONE: ____________
I assume "NAME" touches the left page margin, and the rule at the
right of "PHONE" touches the right page margin.
"NAME" exemplifies a variable "text-1", and "PHONE" is "text-2".
Then there are "rule-1" (left-hand rule) and "rule-2" (right-hand
rule). From left to right, there are spaces "space-1", "space-2",
and "space-3" between some "text" and some rule. So the line is
composed as
text_1 space_1 rule_1 space_2 text_2 space_3 rule_2
This way we have 7 "things". Each one will have a minimum width.
text_1 and text_2 will be "given" by each situation, their
minimum widths t_1 and t_2 can be found by \settowidth.
The minimum widths of the other 5 "things" is not clear to me,
please specify them. Call them s_1, r_1, s_2, s_3, r_2. You may
have ideas about s_1, s_2, s_3 that stay fixed for the entire
task, kind of style parameter. r1 and r2 may be specified by
templates, measure them by \settowidth or so.
The mimimum widths add to some m:
m = t_1 + s_1 + r_1 + s_2 + t_2 + s_3 + r_2
Let l be the length of a line according to the page design
(\linewidth), and let d be the difference l - m (let's hope
it's never negative). In order to ensure that all the "things"
fill the line (that text_1 touches the left margin and rule_2
touches the right margin), you must specify what of the seven
"things" to *stretch* by what amount. In general, the 7 things
will get *actual* widths that may be larger than the minimum
widths. For doing this by programming with TeX, you must
specify *functions* that determine the stretch component.
A simple approach would be saying that each of the 7 things
should get an actual width a_i determined as
a_i = m_i + d_i
where m_i is the minimum width of the thing and the d_i
add up to d:
d = d_1 + d_2 + ... + d_7
E.g., you might say that each d_i should be d/7, so each
thing is stretched by the same amount.
You can simplify the situation by saying that text_1,
text_2 and the spaces should not be stretched at all,
only the rules should be stretched, e.g. by adding d/2
to each minimum width. Or it may be more reasonable to
say that a rule gets an actual length a_i such that it
is a "fixed" multiple of its minimum length m_i (to avoid
that a rule gets much longer than ever needed), "fixed"
for the line but varying over lines:
a_i = f m_i
so
m_i + d_i = f m_i,
d_i = (f - 1) m_i,
d = (f - 1) (r_1 + r_2)
which determines f etc.
Some posters have already provided the *code* for doing
something similar, or more abstractly, algorithms for
determining certain dimensions that could be used to
meet a specification as above, maybe even the same ...
this would be the next thing I would like to find out,
but I must stop now. E.g., why have they referred to
5 inches?
To summarize, we have an example of the frequent issue
that intentions may be characterized by many parameters,
so many that you can't determine them from one or two
examples. You should also try to state some rules/algorithms.
Cheers,
Uwe.
More information about the texhax
mailing list