# [Tex/LaTex] How to construct a logic argument with colored hline with length under control

arrayscolormath-operatorsrules

How to construct a logic argument like this one?

I can construct it like this:

Latex of my argument:

\documentclass[10pt]{article}

\usepackage{newtxtext}
\usepackage{newtxmath}

\begin{document}
$\begin{array}{rl} & p \\ & p \to q \\ \cline{2-2} \therefore & q \end{array}$
\end{document}

There are three things I don't know how to do:
1) how to color the hline
2) how to control the length of the hline so it does not go beyond "p \to q"?
3) how to make the therefore symbol closer to q?

Basically, I need to construct one as close as possible to the first one.

You can use a simple tabular and colortbl:

\documentclass{article}
\usepackage{colortbl}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{tabular}{c@{\,}l@{}}
& $p$ \\
\arrayrulecolor{blue}    & $p \to q$ \\\cline{2-2}
$\therefore$         & $q$ \\
\end{tabular}
\end{document}

You can change the color of the line using xcolor

\documentclass{article}
\usepackage{colortbl,xcolor}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{tabular}{c@{\,}l@{}}
& $p$ \\
\arrayrulecolor{blue!60!green!70}    & $p \to q$ \\\cline{2-2}
$\therefore$         & $q$ \\
\end{tabular}
\end{document}

Same works with arrays also (since the MWE is given using arrays):

\documentclass[10pt]{article}
\usepackage{colortbl,xcolor}
\usepackage{newtxtext}
\usepackage{newtxmath}

\begin{document}
$\begin{array}{c@{\,}l@{}}\arrayrulecolor{blue!60!green!70} & p \\ & p \to q \\ \cline{2-2} \therefore & q \end{array}$
\end{document}