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.

See this example screenshot for clear idea; See this example screenshot for clear idea

  • Welcome to TeX.SE! Please, privide an MWE (Minimal Working Example), a small but complete document, which reproduce your problem. In general \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, 2020 at 22:26
  • @Zarko, thanks for the comment. I edited the question and added a screenshot. Please check the question now.
    – Pratyya10
    Aug 31, 2020 at 22:46
  • 1
    Please copy and paste the minimal amount of code you need to make that screenshot.
    – Teepeemm
    Aug 31, 2020 at 23:06
  • Any news? You receive two answer ... does any of them solve your problem and fulfill your expectation? Please accept it (by clicking on the check mark at the top left side of answer).
    – Zarko
    Oct 1, 2020 at 10:32

2 Answers 2


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

\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

As starting point:


$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

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .