PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : \vbox Tex - Vertikale Ausrichtung



ctansearch
30-08-2012, 01:45
Hallo,
eine Frage zu \vbox

Bei

\vbox to 0pt{}
richtet TeX den Text an der oberen Kante der Box aus, bei


\vbox spread 0pt{}
richtet TeX den Text an der unteren Kante der Box aus.

Weiß jemand, wie man TeX dazu bringt, bei "spread" an der oberen Kante auszurichten?

sommerfee
30-08-2012, 08:04
\vbox to 0pt{}
richtet TeX den Text an der oberen Kante der Box aus

Welchen Text? Innerhalb der \vbox, außerhalb der \vbox, ...?



\vbox spread 0pt{}
richtet TeX den Text an der unteren Kante der Box aus.

Welchen Text?


Weiß jemand, wie man TeX dazu bringt, bei "spread" an der oberen Kante auszurichten?

Trübe meine Glaskugel ist...

ctansearch
30-08-2012, 12:34
TeX-Code



\parindent=0pt
\hbox{\vbox spread 0pt{\hsize=5cm spread spread spread spread spread spread
spreadspread spread spread spread spread spread spread spread spread spread spread
spreadspread spread spread spread spread}
\hskip4cm
\vbox to 0pt{\hsize=5cm to to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to to}}
\vskip4cm
\hbox{\vbox to 30pt{\hsize=5cm to to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to to}
\hskip4cm
\vbox spread 30pt{\hsize=5cm spread spread spread spread spread spread
spreadspread spread spread spread spread spread spread spread spread spread spread
spreadspread spread spread spread spread}}
\end

rstuby
30-08-2012, 13:12
Du solltest doch langsam wissen, dass hier lauffähige Minimalbeispiele gefragt sind...

\documentclass{scrreprt}
\parindent=0pt
\begin{document}

\fbox{
\hbox{\vbox spread 0pt{\hsize=5cm spread spread spread spread spread spread
spreadspread spread spread spread spread spread spread spread spread spread spread
spreadspread spread spread spread spread}
\hskip4cm
\vbox to 0pt{\hsize=5cm to to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to to}}
}
\vskip4cm
\fbox{
\hbox{\vbox to 30pt{\hsize=5cm to to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to to}
\hskip4cm
\vbox spread 30pt{\hsize=5cm spread spread spread spread spread spread
spreadspread spread spread spread spread spread spread spread spread spread spread
spreadspread spread spread spread spread}}
}
\end{document}
Allerdings weiß ich keine Antwort. Ich habe noch nie mit \hbox und \vbox gearbeitet, ich sehe immer nur die entsprechenden Meldungen in der Ausgabe :-)

rais
30-08-2012, 18:19
Moin moin,

Du solltest doch langsam wissen, dass hier lauffähige Minimalbeispiele gefragt sind...

das war schon eins -- für plain TeX.;)

@ctansearch: mir ist nicht klar, worum es Dir eigentlich geht, aber wenn \vbox spread 0pt {...} Dir die richtige Höhe beschert und \vbox to 0pt {...} die richtige Ausrichtung, hättest Du dann nicht mit


\vbox to 0pt {\vbox spread 0pt {...}}
das Gewünschte?

MfG

rstuby
30-08-2012, 18:29
das war schon eins -- für plain TeX

Ach sooo! Ich hab mich schon gewundert: Da kommt einer, der fortgeschrittener ist als ich, und macht so einen Anfängerfehler :-)

klops
30-08-2012, 20:00
das war schon eins -- für plain TeX.;)

Fehlte dafür nicht das \bye?

rais
30-08-2012, 21:19
Fehlte dafür nicht das \bye?
das hab ich auch erst vermisst.
So ich das richtig verstanden hab, ist \end die eigentliche TeX-Primitive, womit TeX das Skriptende angezeigt wird.
\bye ist das bevorzugte Makro zum Beenden. Es besteht aus `\vfill\eject\end', d.h. die letzte Seite wird ggf. mit Freiraum gefüllt (\vfill), ausgegeben (\eject) und TeX wird aufgefordert, sich zu beenden (\end).
Da der OP \end verwendet hat, fehlt \vfill\eject -- im Umkehrschluss wird die letzte Seite nicht mit Freiraum befüllt und wird schlimmstenfalls gar nicht ausgegeben, aber zumindest `fertig' sollte TeX werden.

MfG

ctansearch
30-08-2012, 22:10
Vielen Dank für die Antworten.

@rais: Die Lösung mit verschachtelten Boxen bringt nicht das gewünschte Ergebnis und ich möchte auch sowenig wie möglich auf Verschachtelung zurückgreifen, da das Macro, an dem ich gerade schreibe, auch so schon genügend Verschachtelungen nötig macht.
Ausserdem wollte ich gerne ein Antwort auf genau die Frage:"Weiß jemand, wie man TeX dazu bringt, bei "spread" an der oberen Kante auszurichten?", weil in diesem Fall die vielen möglichen "Workarounds" nicht die Lösung sein sollen, in dem Sinne, daß ich einen möglichst "schlanken" Code schreiben will.

@rstuby
:) Danke für das LaTeX - Beispiel


Wenn ich das Problem genauer beschreiben kann, stelle ich nochmal was ein.

cgnieder
30-08-2012, 22:47
Der Punkt mit der Ausrichtung ist so nicht richtig. Der Unterschied ist ein anderer. Aus TeX by Topic (http://texdoc.net/pkg/texbytopic) (Hervorhebung von mir):


The size of a box can be specified in advance with a box specification ; see above for the syntax.
Any glue in the box is then set in order to reach the required size. Prescribing the size of the box
is done by

\hbox to dimen {...}, \vbox to dimen {...}
If stretchable or shrinkable glue is present in the box, it is stretched or shrunk in order to
give the box the specified size. Associated with this glue setting is a badness value (see
Chapter 8). If no stretch or shrink – whichever is necessary – is present, the resulting box
will be underfull or overfull respectively. Error reporting for over/underfull boxes is treated
below.
Another command to let a box have a size other than the natural size is

\hbox spread dimen {...}, \vbox spread dimen {...}
which tells TeX to set the glue in such a way that the size of the box is a specified
amount more than the natural size.


Ein Beispiel, an dem man das sehen kann:


\parindent=0pt
\def\hhrule{\vbox{\hbox to \hsize {}}\hrule}

spread \vbox spread 10pt {\hrule height 20pt depth 0pt width 1pt}

\hhrule

to \vbox to 10pt {\hrule height 20pt depth 0pt width 1pt}

\hhrule

spread \vbox spread 10pt {\hrule height 0pt depth 20pt width 1pt}

\hhrule

to \vbox to 10pt {\hrule height 0pt depth 20pt width 1pt}

\bye

Grüße

ctansearch
30-08-2012, 23:20
@cgnieder

Guter Hinweis. Ich kann leider momentan nicht im TeXbook nachlesen. Wenn ich es richtig verstehe, wäre mein Problem damit gelöst, wenn TeX den glue nicht vor dem Text, sondern nach dem Text einfügen würde. Hast Du dazu eine Idee?

\vfill etc bringt keinen Effekt.

u_fischer
31-08-2012, 09:58
Hallo,
eine Frage zu \vbox

Bei

\vbox to 0pt{}
richtet TeX den Text an der oberen Kante der Box aus, bei

Nicht wirklich. Eine \vbox der Größe 0pt hat nicht wirklich sowas wie eine obere oder untere Kante. Aber da sie zu voll ist, läuft sie einfach nach unten hin über.




\vbox spread 0pt{}
richtet TeX den Text an der unteren Kante der Box aus.

Weiß jemand, wie man TeX dazu bringt, bei "spread" an der oberen Kante auszurichten?

Wenn du eine Ausrichtung an der oberen Kante haben willst, solltest du korrekt \vtop nehmen:


\documentclass{scrreprt}
\parindent=0pt
\begin{document}

vbox\fbox{\vbox{\hsize=5cm to to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to to}}
%
%
vtop\fbox{\vtop{\hsize=5cm to to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to to}}


axb\fbox{\vtop spread 30pt{\hsize=5cm spread spread spread spread spread spread
spreadspread spread spread spread spread spread spread spread spread spread spread
spreadspread spread spread spread spread}}

\vspace{1cm}

zu voll:
\fbox{\vbox to 1cm {\hsize=5cm to to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to to}}
%
%
zu voll:
\fbox{\vtop to 1cm {\hsize=5cm to to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to to}}


\vfill
spread
\fbox{\vbox spread 1cm {\hsize=5cm to to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to to}}
%
%
spread
\fbox{\vtop spread 1cm {\hsize=5cm to to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to toto to to to to to to to to to to to to}}



\end{document}

ctansearch
31-08-2012, 15:49
Klappt , danke!