For example :
#1 the height #2 the depth
\def\mystrut(#1,#2){\vrule height #1pt depth #2pt width 0pt}
example :
\documentclass{scrartcl}
\begin{document}
\def\mystrut(#1,#2){\vrule height #1pt depth #2pt width 0pt}
\fbox{\mystrut(18,10) qk}
\end{document}
You seem to be misunderstanding what vertical and horizontal modes are.
First of all, let me consider the relationship between vertical and horizontal mode. TeX always starts off in vertical mode.
Under certain circumstances (precisely when it sees a horizontal command), TeX leaves vertical mode and starts horizontal mode in order to make paragraphs. You can't “leave” this mode in other ways than ending the paragraph.
You're probably misled by the name of the \leavevmode
command, which could have been named something like \StartMakingAParagraphIfItMakesSense
; the command does \unhbox\v@idbox
and \unhbox
is a horizontal command, so
- (unrestricted) horizontal mode is started if TeX was in vertical mode,
- nothing happens if TeX is in horizontal mode or in math mode.
The only way to end unrestricted horizontal mode is by issuing (explicitly or implicitly) a primitive \par
command. Every vertical command, if found when TeX is in unrestricted horizontal mode, issues a \par
token.
Note that \par
might not mean the primitive \par
, but the redefined \par
should at some point execute the primitive \par
or strange things will happen: the simple
\def\par{}
x\vskip1pt
will start an infinite loop, for example, because \vskip
will continue to issue \par
in order to be executed in the vertical mode that's never reached.
You can start vertical mode when in horizontal mode by opening a \vbox
or \vtop
, but the resulting list will eventually be appended to the horizontal list being built, so this doesn't seem what you're looking for.
There is an escape to the surrounding vertical mode: if TeX finds \vadjust{...}
in (unrestricted) horizontal mode, it will package the vertical list given as argument, and this list will be inserted between the line where the command happens to be and the next one, after the paragraph has been formed. Such a vertical list will be appended before the interline glue. So
abc\vadjust{\vskip3pt} text text ... text
will have 3pt of additional vertical space between the first and second lines of the paragraph.
There is no symmetry between vertical mode and horizontal mode, because they do very different things.
Best Answer
The
\leavevmode
is defined by LaTeX and plainTeX and ensures that the vertical mode is ended and horizontal mode is entered. In vertical mode, TeX stacks horizontal boxes vertically, whereas in horizontal mode, they are taken as part of the text line.For example
\mbox{..}
is defined as\leavevmode\hbox{..}
to ensure that horizontal mode is entered if it is used at the beginning of a paragraph. If you only use\hbox{ }
it is stacked above the following paragraph instead.Compare:
Result:
with:
Result:
You see that in the first case the
\hbox
is stacked with the two paragraphs vertically (but without paragraph indention) because it is processed in vertical mode. In the second case horizontal mode is entered first and soHello
is processed as part of the second paragraph.For further reading about
\leavevmode
please see "The TeXBook" by Donald E. Knuth, Appendix A, section 13.1, page 313 as well Appendix B, page 356.