TeX - LaTeX Asked on July 29, 2021
A form that is meant to be printed and filled via handwriting provides a field for a multiline value that can be filled by long text. It is rendered like this:
+-----------------------------------+
| |
| --------------------------------- |
| |
+-----------------------------------+
So there are two lines with a horizontal rule as guidance for filling the value. I can create this easily with
documentclass{article}
begin{document}
fbox{
begin{tabular}{p{10cm}}
rule{0pt}{1em} hline
rule{0pt}{1em}
end{tabular}
}
end{document}
However, I now want to add the possibility to fill this field from inside LaTeX, so that it is rendered like this:
+-----------------------------------+
| Lorem ipsum dolor sit amet, con- |
| --------------------------------- |
| sectetur adipiscing elit, sed do |
+-----------------------------------+
i.e. I want to give a continuous text value and want LaTeX to properly place it inside the existing lines like a paragraph, with proper word-wrap and spacing. The rendering should otherwise be identical to the empty variant (it is okay for values to destroy the layout if they are too long).
I figure to do this, I would need to throw away the tabular and use a minipage or something that draws horizontal lines between the text lines. At the end of the text I would need to fill additional horizontal lines if the text was too short to produce all expected lines.
How can I do that?
To avoid misconceptions: I do not wish to generate an interactive form of any kind.
You can put the text in a multirow
, but contrary to the normal usage of multirow
, leave the horizontal lines in place. You might have to apply a baselinestretch
to get the lines positioned properly. And maybe you have to set some parameters to encourage hyphenation.
documentclass{article}
usepackage{multirow}
begin{document}
begin{tabular}{|p{6cm}|}
hline
rule{0pt}{1em}multirow[t]{2}{=}{renewcommand{baselinestretch}{1.1}normalsize
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do}
hline
rule{0pt}{1em}
hline
end{tabular}
end{document}
Correct answer by Pieter van Oostrum on July 29, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP