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

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

  • 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
  • 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. – Torbjørn T. Dec 18 '16 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.