0

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

4
  • 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

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
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}

enter image description here

You must log in to answer this question.

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