# tikz: Draw horizontal line of some specified width

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}

• \draw (start coordinate) -- (x length, y length)? – Guilherme Zanotelli Dec 15 '16 at 18:13
• Also, \rule{thickness}{width}, for non tikz... – Guilherme Zanotelli Dec 15 '16 at 18:21
• \draw(start)--+(length,0); – Symbol 1 Dec 15 '16 at 18:22
• @GuilhermeZanotelli - Shouldn't that be +(x length, y length) or ++? Also, its \rule{width}{thickness}. – John Kormylo Dec 16 '16 at 1:32
• Useful informations in A line of length \textwidth in TikZ – Paul Gaborit Dec 16 '16 at 6:31

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

• Length, not width, I believe. – Torbjørn T. Dec 17 '16 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 '16 at 9:36
• 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. – Torbjørn T. Dec 18 '16 at 9:41