7

How can I move the text in the following table closer to the upper rule (or closer to the lower rule) without changing row height:

{\halign
{#\cr
\hrulefill\cr
\font\f=cmr8\f(bla bla bla)\cr
\hrulefill\cr}}

enter image description here

I'm looking for a solution with plain TeX.

UPDATE (what I am trying to achieve)

I am trying to center a couple of words in the right-hand side of the text area of a page, below row baseline and in tiny font size (7-8pt is OK). To accomplish this, I set up a table with two columns where each column takes up half of the text area, decreased font size and centered the text in the right half of a row. (I am using a table because there are other texts above and below this one which should start at the middle of the row. Also, there are texts that should start at the beginning of certain lines but none of these texts need to go beyond the middle of the page. All this was easy to achieve with a table.) Next, I thought the area right below the baseline was probably not enough for 7-8pt letters so I decided to put the tiny text in the upper part of next row, preferably without changing the height of this row. I tried \vskip but I was not able to make it do what I want.

I have not examined all suggestions yet but \raise does not seem to be what I am looking for, as it changes row height.

UPDATE 2 (details and a sketch)

Grey lines in the sketch below mark cell borders; they are only shown as a hint at document layout and should not exist in the final document. Black horizontal lines indicate fill-in blanks and should exist in the final document at the baseline (actually, I will decide whether I want them at the baseline or slightly below it but for now let's assume they are at the baseline). Texts in parentheses indicate what is to be filled-in in the blanks above them.

What I am trying to achieve is to place each of the parenthesized texts below the corresponding fill-in blank, centered according to the length of the blank.

P.S. For the curious, "дата" means date, "гр." stands for city, "декларатор" means declarant, "подпис" means signature, "име и фамилия" means first and last name.

enter image description here

  • You might want to go back to your previous questions and choose an answer as "accepted answer" if there is one which helped you. If not, edit the questions for clarifications. – morbusg Jun 1 '14 at 14:05
  • Could you edit in a demo showing the general set up you have? I suspect that would help in getting good answer(s). – Joseph Wright Jun 2 '14 at 6:29
  • 1
    I tried to understand the update, but I can't figure out what you mean. Maybe a sketch would better illustrate the problem. – egreg Jun 2 '14 at 9:58
1

The sketch mentioned in the question can be printed (for example) by the following code. No \halign is needed.

\def\l#1#2{\line{\hbox to.5\hsize{#1\hfil}\hbox to.5\hsize{#2\hfil}}}
\def\ul{\leaders\vrule height-1pt depth1.4pt \hfill}
\def\ra#1{\raise8pt\hbox{\sevenrm#1}}
\baselineskip=18pt

\l {Data: \ul \qquad} {}
\l {gr. \ul \qquad}   {Deklarator:}
\l {} {}
\l {} {\ul}
\l {} {\hfil\ra{(podpis)}}
\l {} {/\ul /}
\l {} {\hfil\ra{(ime i familija)}}

\end

Sorry, I didn't use cyrillic. I hope that you are able to use appropriate encoding/TeXengine/font to get these special letters.

4

enter image description here

{\halign
{#\cr
\hrulefill\cr
\font\f=cmr8\f(bla bla bla)\cr
\hrulefill\cr}}


\bigskip

{\halign
{#\cr
\noalign{\hrule}
\font\f=cmr8\f(bla bla bla)\cr
\noalign{\hrule}}}

\bye

you can insert\vskip in the \noalign before or after each of the rules to add as much space as you want.

  • I'm looking for a way to move the text closer to the rulers, no the other way around. – SJU Jun 1 '14 at 0:42
  • @AngelTsankov It's the same thing, motion is relative:-) but having got the close spacing as here you can insert whatever space you want above or below each of the rules with \vskip 3pt or whatever – David Carlisle Jun 1 '14 at 1:01
3

Don't define font in table cells. Define the ones you need at the start of the document.

Here are three commands that try to emulate the ones in the LaTeX package booktabs.

\def\toprule{\noalign{\hrule height 0.8pt\kern1pt}}
\def\midrule{\noalign{\kern1pt\hrule\kern1pt}}
\def\bottomrule{\noalign{\kern1pt\hrule height 0.8pt}}

\def\computestrut#1{%
  \dimen0=#1\relax
  \setbox\strutbox=\hbox{\vrule height .7\dimen0 depth .3\dimen0 width 0pt}%
}

\font\smallrm=cmr8

\leavevmode\vbox{
  \offinterlineskip
  \computestrut{10pt}\smallrm
  \halign{\strut#\hfil\cr
  \toprule
  (bla bla bla)\cr
  \midrule
  (bla bla bla)\cr
  \bottomrule
}}
\vbox{
  \offinterlineskip
  \halign{\strut#\hfil\cr
  \toprule
  (bla bla bla)\cr
  \midrule
  (bla bla bla)\cr
  \bottomrule
}}

\bye

With \offinterlineskip and \strut you ensure constant cell height (if they don't contain material with excessive height or depth). You can compute the strut (do it only locally) so that it matches the font size you want to use.

enter image description here

2

Are you looking for a simple \raise or \lower operation?

\font\f=cmr8\f
\halign
{#&#&#\cr
\noalign{\hrule}
         \hbox{(bla bla bla)} & % Box just to be systematic
\raise4pt\hbox{(bla bla bla)} &
\lower4pt\hbox{(bla bla bla)} \cr
\noalign{\hrule}
}
\bye

Of course this requires a box but that's normally the best way to move stuff about in an arbitrary way.

If you want to ignore the height/depth entirely, combine with \smash

\font\f=cmr8\f
\halign
{#&#&#\cr
\noalign{\hrule}
         \hbox{(bla bla bla)} & % Box just to be systematic
\smash{\raise4pt\hbox{(bla bla bla)}} &
\smash{\lower4pt\hbox{(bla bla bla)}} \cr
\noalign{\hrule}
}
\bye
1

Plain TeX defines \strut independent of size of selected font because it supposes the 10/12pt typesetting only:

\newbox\strutbox
\setbox\strutbox=\hbox{\vrule height8.5pt depth3.5pt width0pt}
\def\strut{\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi}

If you will set various font sizes then it is very useful to redefine the plain TeX's definition in such way:

\def\strut{\lower.35em\vbox to1.2em{}}

Note: the em unit is used, it depends on the size of the current font. No \computestrut macro is needed. This re-definition gives the same result for 10pt fonts as above.

The question here includes a new singular request: to do the whole strut fixed, independent of the font size, but the height of the strut have to be dependent on the font size. This can be done by

\def\strut{\raise.85em\vtop to12pt{}}

The code:

\def\strut{\raise.85em\vtop to12pt{}}

\vbox{\offinterlineskip
\halign{#\unskip\strut\hfil  \cr \noalign{\hrule}
   here is 10pt text         \cr \noalign{\hrule}
   \sevenrm here is 7pt text \cr \noalign{\hrule}
   \fiverm here is 5pt text  \cr \noalign{\hrule}
}}
\end

Generates the following result:

strut

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.