4

I wonder how to draw a horizontal line of some specified length. MWE is given below. Any help will be highly appreciated. Thanks

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}

\node (a) at (0, 0) {Test \hrulefill{}};

\end{tikzpicture}

\end{document}
8

1 Answer 1

8

You can use line width to get a satisfactory line width. This is an example for this purpose,

\documentclass[border={5pt}]{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\foreach \x in {1,...,5}
\draw[line width=\x mm] (0,\x) -- (2,\x);
\end{tikzpicture}

\end{document}

and the result is

enter image description here

3
  • Length, not width, I believe. Dec 17, 2016 at 18:19
  • @TorbjørnT., length is determined based on the coordinates. There is nothing mysterious in the length. I do believe the OP wanted the width.
    – CroCo
    Dec 18, 2016 at 9:36
  • 1
    Appears, based on the acceptance, that you were right (so +1). I know there's nothing mysterious about the length of course, it's just entirely unclear to me that the OP could in any way mean the line width, but I suppose that could be a linguistic misunderstanding. Dec 18, 2016 at 9:41

You must log in to answer this question.

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