Whenever I am using \line command or the tikz package to draw a line, it is giving me a straight line as output. But the problem is, the straight line is aligned to vertical bottom. Whereas I want it aligned to vertical middle. -------------- gives the expected output, but rather than using an unknown number of dashes to format a draft, I want a command to do that. Is there any command that can fulfil my expectation? Thanks in advance.
Asked
Active
Viewed 476 times
0
2 Answers
1
You of course do not need any tikz magic. This is possible in plain TeX
Some text\leaders\hrule height 3.4pt depth -3pt\hskip 2cm some other text
See also Vertically centered horizontal rule filling the rest of a line?
You can define your own command e.g. as follows
\def\centerrule{%
\dimen0=-.4ex
\advance\dimen0 by 0.4pt
\leaders\hrule height.4ex depth\dimen0\hskip
}
Then you can write
Some text\centerrule 2cm some other text %the line is 2cm long
Some text\centerrule 0cm plus 1fill some other text %the line stretches to
%fill the whole line
Daniel
- 246
0
As starting point:
\documentclass{article}
\usepackage{tikz}
\begin{document}
$x+y=4$ \tikz[baseline=-0.5ex]\draw (0,0) -- (2,0); (1) some text
$x+y=4$ \tikz\draw[dashed] (0,0) -- (2,0); (1) some text
\end{document}
Zarko
- 296,517


\draw (<coordinate 1> -- (<coordinate 2);draw straight line between given coordinates. So it is not entirely clear (at least to me), what is your problem. – Zarko Aug 31 '20 at 22:26