0

How do I control the placement of this logicproof on the page? I want it to stretch horizontally across the page regardless of the content. The spacing should be between the statement and the justification.

\documentclass{article}
\usepackage{logicproof}

\begin{document}
some text
\begin{logicproof}{0}
    statement & justification \\
    \forall x \, P(x) & premise \\
    \forall x \, Q(x) & $\forall x \, \mathrm{i}$ 3--5
\end{logicproof}
\end{document}
JGD
  • 63

2 Answers2

1

The environment logicproofis using the environment tabular. To define a table with a specific width you can use the package/environment tabularx:

\documentclass{article}
\usepackage{logicproof}
\usepackage{tabularx}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\makeatletter
\renewenvironment{logicproof}[1]{%
  \setcounter{lp@line}{0}%
  \setcounter{lp@nested}{0}%
  \setcounter{lp@total@nests}{#1}%
  \setlength{\tabcolsep}{0mm}%
  \let\lp@orig@arraycr\@arraycr%
  \renewcommand{\@arraycr}{\lp@cr}%
  \renewcommand{\@currentlabel}{\p@lp@line\thelp@line}%
  \ifthenelse{%
    0=#1%
  }{%
    \def\lp@tab@format{{r@{~~~}>{$}l<{$}@{~~~~}R}}%%changed l to R
  }{%
    \def\lp@tab@format%
        {{r@{~~~}*{#1}{l}@{~}>{$}l<{$}@{~~~~}l@{~}*{#1}{R}}}%changed l to R
  }%
  \center%
  \begingroup%changed definition
    \edef\x{\endgroup\noexpand\tabularx{\linewidth}{\lp@tab@format}}
    \x%
  \lp@start@proof@line%
}{%
  \lp@stop@proof@line%
  \endtabularx%
  \endcenter%
  \setcounter{lp@total@nests}{0}%
  \ifthenelse{%
    0=\value{lp@nested}
  }{% All is well.
  }{% There are still open subproofs.
    \def\@currenvir{subproof}%
  }
}

\makeatother
\begin{document}
some text
\begin{logicproof}{0}
    statement & justification \\
    \forall x \, P(x) & premise \\
    \forall x \, Q(x) & $\forall x \, \mathrm{i}$ 3--5
\end{logicproof}
\end{document}
Marco Daniel
  • 95,681
  • Your example does not compile to the desired result. I can't claim to understand the code and you've provided no explanation on how to use it. – MarcinKonowalczyk Mar 22 '17 at 12:38
  • @MarcinKonowalczyk: Why do you think so? I got no error. The table has a width of \linewidth. I added a new column type to get another justification. – Marco Daniel Mar 22 '17 at 12:57
  • I got no error either. It's just that when I run your code I got a table without the additional spacing. It works now though. Cheers. :) – MarcinKonowalczyk Mar 22 '17 at 12:59
  • I would suggest defining the \linewidth in the changed definition as a separate dimension, or otherwise making it clear that this is the value one needs to change to get, for example, 0.5\linewidth logicproof. – MarcinKonowalczyk Mar 22 '17 at 13:01
  • @MarcinKonowalczyk: Indeed. I will add it. – Marco Daniel Mar 22 '17 at 13:28
1

@MarcoDaniel's answer is a very in-depth solution. I offer a slightly worse, less professional and down to the ground one. Just insert a space:

\documentclass{article}
\usepackage{logicproof}

\newdimen\logicgap
\logicgap=0.5\textwidth

\begin{document}
some text
\begin{logicproof}{0}
    statement & \hspace{\logicgap} justification \\
    \forall x \, P(x) & \hspace\logicgap premise \\
    \forall x \, Q(x) & \hspace\logicgap $\forall x \, \mathrm{i}$ 3--5
\end{logicproof}
\end{document}

To understand how lengths work in LaTeX, see this post.