1

I have a command to draw some lines through a text:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
 \begin{document}

\scalebox{0}{%
\begin{tikzpicture}
    \begin{axis}[hide axis]
        \addplot [
        color=orange,
        solid,
        line width=1.3pt,
        forget plot
        ]
        (0,0);\label{oranged}
        \addplot [
        color=red!30.6!green!0!blue!55.7!,
        densely dashed,
        line width=1.7pt,
        forget plot
        ]
        (0,0);\label{purpled}
        \addplot [
        color=green,
        dash pattern={on 10pt off 2pt},
        line width=1.6pt,
        forget plot
        ]
        (0,0);\label{greened}
    \end{axis}
  \end{tikzpicture}%
}%


 I have \ref{purpled} and \ref{oranged}  and \ref{greened}.


 \end{document}

This command creates lines with a special length. I did anything to increase the length of the lines, although I was not succesful. does anyone know how we reach this goal.

1
  • Hi! I'm not sure what are you trying to do; pgfplots if for drawing graphics. Are you sure you don't want some of the text underlining/highlighting packages? Can you add a (even handmade) sketch with the result you are looking for?
    – Rmano
    Commented Dec 31, 2021 at 9:59

1 Answer 1

2

Not sure I understand exactly what you are attempting to do, but it is better to just use tikz directly to draw instead of using pgfplots.

In the code below, the \DrawLine macro will draw a line of a given length with given draw parameters. I used \DrawLine to define \Purpled, \Greened and \Oranged which yields the second line below:

enter image description here

Code:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}

\newcommand*{\DrawLine}[2][]{%
    \tikz [baseline] \draw [#1] (0,0.5ex) -- ++(#2,0);%
}
\newcommand*{\Purpled}[1]{%
    \DrawLine[
        draw=red!30.6!green!0!blue!55.7!, 
        dash pattern={on 10pt off 2pt}, 
        densely dashed,
        line width=1.6pt,
    ]{#1}%
}
\newcommand*{\Greened}[1]{%
    \DrawLine[
        draw=green,
        dash pattern={on 10pt off 2pt},
        line width=1.6pt,
    ]{#1}%
}
\newcommand*{\Oranged}[1]{%
    \DrawLine[
        draw=orange,
        solid,
        line width=1.3pt,
    ]{#1}%
}


\begin{document}
\scalebox{0}{%
\begin{tikzpicture}
    \begin{axis}[hide axis]
        \addplot [
        color=orange,
        solid,
        line width=1.3pt,
        forget plot
        ]
        (0,0);\label{oranged}
        \addplot [
        color=red!30.6!green!0!blue!55.7!,
        densely dashed,
        line width=1.7pt,
        forget plot
        ]
        (0,0);\label{purpled}
        \addplot [
        color=green,
        dash pattern={on 10pt off 2pt},
        line width=1.6pt,
        forget plot
        ]
        (0,0);\label{greened}
    \end{axis}
  \end{tikzpicture}%
}%


 I have \ref{purpled} and \ref{oranged}  and \ref{greened}.

 I have \Purpled{0.65cm} and \Oranged{1.0cm}  and \Greened{1.0cm}.

\end{document}
1
  • You seem to be so generous and intelligent!!! Commented Dec 31, 2021 at 11:04

You must log in to answer this question.

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