How to construct a logic argument with colored hline with length under control?
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}
I'd define an environment for this. Adjust the spacing (I used \enspace
) and the color (here blue!50
) to suit you.
\documentclass{article}
\usepackage{xcolor,colortbl,array,amssymb}
\newenvironment{deduction}
{\begin{tabular}{@{}>{$}c<{$}@{\enspace}>{$}l<{$}@{}}\arrayrulecolor{blue!50}}
{\end{tabular}}
\newcommand{\premise}[1]{\\}
\newcommand{\conclusion}[1]{\cline{2-2}\therefore}
\begin{document}
\begin{deduction}
\premise{p}
\premise{p\to q}
\conclusion{q}
\end{deduction}
\end{document}
Another possible solution:
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath,amssymb}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node[yshift=-0.2ex]({#1}) {};}
\newcommand{\tikzhline}[3][1]{\tikz[overlay,remember picture]\draw[thick,cyan,shorten <=-{#1}pt,shorten >=-{#1}pt](#2.south)--(#3.south);}
\begin{document}
\[
\begin{array}{r@{\extracolsep{5pt}}l}
& p\\
& \tikzmark{a}p\rightarrow q\tikzmark{b}\\
\tikzhline{a}{b}
\therefore & q
\end{array}
\hspace*{0.5cm}
\begin{array}{r@{\extracolsep{7pt}}l}
& p\\
& \tikzmark{c}p\rightarrow q\tikzmark{d}\\
\tikzhline[6]{c}{d}
\therefore & q
\end{array}
\]
\end{document}
The result:
You will control the length by means of the optional parameter of \tikzhline
.