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}

2 Answers 2

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}
5
  • 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. Mar 22, 2017 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. Mar 22, 2017 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. :) Mar 22, 2017 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. Mar 22, 2017 at 13:01
  • @MarcinKonowalczyk: Indeed. I will add it. Mar 22, 2017 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.

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.