5

I'm typesetting a natural deduction proof. These consist of several numbered statements along with justifications. I'm using the logicproof package, and a minimal example looks something like this:

\documentclass[article]
\usepackage{logicproof}
\begin{document}
text
\begin{logicproof}{0}
    statement & justification
\end{logicproof}

It compiles into this (black bars show geometry of page): Logicproof is in the centre of the page

I'd like the proof to be aligned on the left (as with the rest of the text), but I can't see any mention of how to do this in the package documentation. I believe that the package uses tabular under the hood.

I've tried to redefine \center to hack around this, and the following code seems to do the trick - but I'm unsure if this is good practice or not.

\def\center{\trivlist\item\relax}
\def\endcenter{\endtrivlist}

My attempt

Is there a better approach? Should I use \renewcommand instead?

3

In the definition of the logicproof environment the commands \center and \endcenter are used.

The easiest way to fix this is by using the \patchcmd command from the etoolbox package:

\documentclass{article}
\usepackage{logicproof,etoolbox}

\patchcmd{\logicproof}{\center}{\flushleft}{}{}
\patchcmd{\endlogicproof}{\endcenter}{\endflushleft}{}{}

\begin{document}
\noindent text
\begin{logicproof}{0}
    statement & justification
\end{logicproof}

\end{document}

Another fix is to simply replace these with \flushleft and \endflushleft in a \renewenvironment{logicproof} in your preamble:

\documentclass{article}
\usepackage{logicproof}

\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<{$}@{~~~~}l}}%
  }{%
    \def\lp@tab@format%
        {{r@{~~~}*{#1}{l}@{~}>{$}l<{$}@{~~~~}l@{~}*{#1}{r}}}
  }%
  %\center% <-- REMOVED
  \flushleft% <-- ADDED
  \expandafter\tabular\lp@tab@format%
  \lp@start@proof@line%
}{%
  \lp@stop@proof@line%
  \endtabular%
  %\endcenter% <-- REMOVED
  \endflushleft% <-- ADDED
  \setcounter{lp@total@nests}{0}%
  \ifthenelse{%
    0=\value{lp@nested}
  }{% All is well.
  }{% There are still open subproofs.
    \def\@currenvir{subproof}%
  }
}
\makeatother

\begin{document}
\noindent text
\begin{logicproof}{0}
    statement & justification
\end{logicproof}

\end{document}

Both solutions yield identical output:

Output

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.