1

With \syllogC, from the syllogism package, the user includes an automatic numeration for the syllogism.

\syllogC{Every man is mortal} %
{Socrates is a man} %
{Socrates is mortal}

will produce something close to:

(S1) Every man is mortal. Socrates is a man. Socrates is mortal.

I think users could benefit from an automatic numeration feature for each component of the syllogism:

(S1) A. Every man is mortal. B. Socrates is a man. C. Socrates is mortal.

This way users could refer easily not only to the entire syllogism but to each internal part of it.

E.g.: As shown in (S1), from the premise (S1A) and the premise (S1B) derives the conclusion (S1C).

What is the best code to implement these subsidiary counters?

MWE:

\documentclass[letterpaper,
          10pt,
          ]{article}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{syllogism}

\begin{document}
\def\preA{All men except Socrates are able to laugh}
\def\preB{Socrates is a man}
\def\Conc{Socrates is not able to laugh}

\syllogC{\preA}{\preB}{\Conc}

\end{document} 
  • 1
    Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Feb 13 '16 at 12:58
  • Perhaps adding this feature would be a good suggestion to the package author – user31729 Feb 13 '16 at 13:27
  • @ChristianHupfer How can I add it myself? – Furbenzio Feb 13 '16 at 20:57
  • Honestly, the package author is the first person to be addressed for change requests. Write the suggestions to him. – user31729 Feb 13 '16 at 21:42
2

There's no need to use a new counter (would be difficult, perhaps)

I used another approach, replacing the list in \@sylloc command with a special sylloglist which is a clone of enumerate, which provides the counter anyway.

The 3rd item is a rule, I have to replace \item ... with \item[] there. The list spacing settings have been incorporated into the optional argument of sylloglist.

\documentclass[letterpaper, 10pt,]{article}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

\usepackage{enumitem}
\usepackage{xpatch}
\usepackage{syllogism}

\newlist{sylloglist}{enumerate}{1}
\setlist[sylloglist,1]{label={\Alph*},ref={(S\csname thec:syl\endcsname\Alph*)}}
\makeatletter

\xpatchcmd{\@syllog}{%
  \begin{list}{}
    {%
      \setlength{\parsep}{\z@}
      \setlength{\itemsep}{\z@}
      \addtolength{\leftmargin}{-1.5em}
      \setlength{\itemindent}{-1ex}
      \setlength{\listparindent}{\itemindent}
    }
  }{%
    \begin{sylloglist}[parsep=\z@,itemsep=\z@,leftmargin={\dimexpr\leftmargin-1.5em},itemindent=-1ex,listparindent=\itemindent]
    }{\typeout{Patching startup of list succeeded}}{\typeout{Patching startup of list failed}}

\xpatchcmd{\@syllog}{%
  \item \rule{\SY@LenRule}{\SY@HiRule}
}{%
  \item[] \rule{\SY@LenRule}{\SY@HiRule}
  }{\typeout{Patching rule item of list succeeded}}{\typeout{Patching rule item of list failed}}
\xpatchcmd{\@syllog}{%
\end{list}
}{\end{sylloglist}}{\typeout{Patching end of list succeeded}}{\typeout{Patching end of list failed}}
\makeatother




\begin{document}
\def\preA{All men except Socrates are able to laugh\label{first}}
\def\preB{Socrates is a man\label{second}}
\def\Conc{Socrates is not able to laugh\label{conclusion}}

\syllogC{\preA}{\preB}{\Conc}


\def\preA{All men except Socrates are able to laugh\label{firstnew}}
\def\preB{Socrates is a man\label{secondnew}}
\def\Conc{Socrates is not able to laugh\label{conclusionnew}}

\syllogC{\preA}{\preB}{\Conc}


In \ref{conclusion} we found that ... whereas in \ref{conclusionnew} it was shown that ...

The statement \ref{first} is the same as \ref{firstnew}


\end{document}

enter image description here

  • Tnank you @Christian, man that was super fast! But how could you refer to each premise? My goal is to be able to refer to, say, premise A, by saying "the premise (S1A) shows that Socrates.." so the conclusion (S1C) is justified. – Furbenzio Feb 13 '16 at 13:18
  • @user82528: I have to change some minor issue – user31729 Feb 13 '16 at 13:19
  • @user82528: See the update please – user31729 Feb 13 '16 at 13:26
  • That's great, thank you. Just one last detail. What if I need to refer to conclusion as "(S1C)" and not as merely "C"? The same for premise A: not "as shown in A" but "as shown in (S1A)"? – Furbenzio Feb 13 '16 at 13:34
  • @user82528: I'll check – user31729 Feb 13 '16 at 13:36
2

The approach of the syllogism package is not very convincing; however, with some patches you can get what you need.

Note that the \label for the whole syllogism has to be placed after it like in the examples, whereas the labels for the single items must go inside them.

\documentclass[letterpaper,
          10pt,
          ]{article}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{syllogism}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\@syllog}
  {\settowidth}
  {\setcounter{sylitem}{0}\settowidth}
  {}{}
\patchcmd{\@syllog}
  {\setlength{\SY@availSpace}}
  {\setcounter{sylitem}{0}\setlength{\SY@availSpace}}
  {}{}
\patchcmd{\syllogC}{\stepcounter}{\refstepcounter}{}{}
\setcounter{c:syl}{1}

\newcounter{sylitem}
\renewcommand{\thesylitem}{\Alph{sylitem}\closeparenref}
\renewcommand{\p@sylitem}{\openparenref S\arabic{c:syl}}
\newcommand{\syllogD}[3]{%
  \syllogC{\sylitem #1}{\sylitem #2}{\sylitem #3}%
}
\newcommand{\sylitem}{\refstepcounter{sylitem}\thesylitem.~}
\@namedef{thec:syl}{S\the\numexpr\arabic{c:syl}-1\relax\closeparenref}
\@namedef{p@c:syl}{\openparenref}
\protected\def\openparenref#1\closeparenref{\textup{(#1)}}
\protected\def\closeparenref{}
\makeatother

\begin{document}
\def\preA{All men except Socrates are able to laugh}
\def\preB{Socrates is a man}
\def\Conc{Socrates is not able to laugh}

\syllogD{\preA\label{syl1A}}{\preB\label{syl1B}}{\Conc\label{syl1C}}\label{syl1}

\syllogD{\preA\label{syl2A}}{\preB\label{syl2B}}{\Conc\label{syl2C}}\label{syl2}

\ref{syl1}--\ref{syl1A}--\ref{syl1B}--\ref{syl1C}

\ref{syl2}--\ref{syl2A}--\ref{syl2B}--\ref{syl2C}

\end{document}

enter image description here

An independent implementation.

\documentclass{article}
\usepackage{booktabs,xparse,amssymb}

\ExplSyntaxOn

\keys_define:nn { syllogism }
 {
  number         .bool_set:N       = \l_syllogism_number_bool,
  number         .default:n        = true,
  label          .tl_set:N         = \l_syllogism_label_tl,
  subnumber      .bool_set:N       = \l_syllogism_subnumber_bool,
  subnumber      .default:n        = true,
  first-premiss  .tl_set:N         = \l_syllogism_first_tl,
  first-premiss  .value_required:n = true,
  second-premiss .tl_set:N         = \l_syllogism_second_tl,
  second-premiss .value_required:n = true,
  conclusion     .tl_set:N         = \l_syllogism_concl_tl,
  conclusion     .value_required:n = true,
 }

\NewDocumentCommand{\sylref}{m}{\textup{(\ref{#1})}}

\NewDocumentCommand{\syllogism}{m}
 {
  \setcounter{syllogismitem}{0}
  \group_begin:
  \keys_set:nn { syllogism } { #1 }
  \bool_if:NT \l_syllogism_number_bool
   {
    \refstepcounter{syllogism}
    \tl_if_blank:VF \l_syllogism_label_tl { \label { \l_syllogism_label_tl } }
    (\thesyllogism)\qquad
   }
  \begin{tabular}{@{}l}
  \bool_if:NT \l_syllogism_subnumber_bool
   {
    \refstepcounter{syllogismitem}
    \thesyllogismitem.~
   }
  \l_syllogism_first_tl
  \\
  \bool_if:NT \l_syllogism_subnumber_bool
   {
    \refstepcounter{syllogismitem}
    \thesyllogismitem.~
   }
  \l_syllogism_second_tl
  \\
  \midrule
  \bool_if:NT \l_syllogism_subnumber_bool
   {
    \refstepcounter{syllogismitem}
    \thesyllogismitem.~
   }
  \l_syllogism_concl_tl \qquad $\therefore$
  \end{tabular}
  \group_end:
 }
\ExplSyntaxOff

\NewDocumentCommand{\openparenref}{u\closeparenref}{\textup{(#1)}}
\NewDocumentCommand{\closeparenref}{}{}

\makeatletter
\newcounter{syllogism}
\renewcommand{\thesyllogism}{S\arabic{syllogism}\closeparenref}
\renewcommand{\p@syllogism}{\openparenref}
\newcounter{syllogismitem}
\renewcommand{\thesyllogismitem}{\Alph{syllogismitem}\closeparenref}
\renewcommand{\p@syllogismitem}{\openparenref S\arabic{syllogism}}
\makeatother


\begin{document}

\syllogism{
  number,
  label=syl1,
  subnumber,
  first-premiss={All men except Socrates are able to laugh\label{syl1A}},
  second-premiss={Socrates is a man\label{syl1B}},
  conclusion={Socrates is not able to laugh\label{syl1C}},
}

\bigskip

\syllogism{
  number,
  label=syl2,
  first-premiss={Mus syllaba est},
  second-premiss={Syllaba autem caseum non rodit},
  conclusion={Ergo mus caseum non rodit},
}

\bigskip

\syllogism{
  first-premiss={Mus syllaba est},
  second-premiss={Mus autem caseum rodit},
  conclusion={Ergo syllaba caseum rodit},
}

\bigskip

References:

\ref{syl1}--\ref{syl1A}--\ref{syl1B}--\ref{syl1C}

\ref{syl2}

\end{document}

enter image description here

A variant that allows to break overlong items in the syllogism. A new key maxwidth has been added (default value \linewidth). The label sticks in the margin of the items if they have to be split across lines (when subnumbering is activated, of course).

\documentclass{article}
\usepackage{booktabs,xparse,amssymb,varwidth,showframe}

\ExplSyntaxOn

\keys_define:nn { syllogism }
 {
  number         .bool_set:N       = \l_syllogism_number_bool,
  number         .default:n        = true,
  label          .tl_set:N         = \l_syllogism_label_tl,
  subnumber      .bool_set:N       = \l_syllogism_subnumber_bool,
  subnumber      .default:n        = true,
  first-premiss  .tl_set:N         = \l_syllogism_first_tl,
  first-premiss  .value_required:n = true,
  second-premiss .tl_set:N         = \l_syllogism_second_tl,
  second-premiss .value_required:n = true,
  conclusion     .tl_set:N         = \l_syllogism_concl_tl,
  conclusion     .value_required:n = true,
  maxwidth       .dim_set:N        = \l_syllogism_maxwidth_dim
 }

\NewDocumentCommand{\syllogism}{m}
 {
  \setcounter{syllogismitem}{0}
  \group_begin:
  \keys_set:nn { syllogism } { maxwidth=\linewidth, #1 }
  \tl_put_right:Nn \l_syllogism_concl_tl { \unskip \nolinebreak\qquad $\therefore$ }
  \noindent
  \bool_if:NT \l_syllogism_number_bool
   {
    \refstepcounter{syllogism}
    \tl_if_blank:VF \l_syllogism_label_tl { \label { \l_syllogism_label_tl } }
    \makebox[3em][l]{(\thesyllogism)}
   }
  \begin{tabular}{@{}l}
  \syllogism_make_text:V \l_syllogism_first_tl
  \\
  \syllogism_make_text:V \l_syllogism_second_tl
  \\
  \midrule
  \syllogism_make_text:V \l_syllogism_concl_tl
  \end{tabular}
  \group_end:
 }

\cs_new_protected:Nn \syllogism_make_text:n
 {
  \begin{varwidth}
   {
    \dim_eval:n
     {
      \l_syllogism_maxwidth_dim
      \bool_if:NT \l_syllogism_number_bool { - 3em }
      - \tabcolsep
     }
   }
  \bool_if:NT \l_syllogism_subnumber_bool
   {
    \leftskip=1.5em
    \refstepcounter{syllogismitem}
    \makebox[0pt][r]{\makebox[1.5em][l]{\thesyllogismitem.}}
   }
  \ignorespaces
  #1
  \end{varwidth}
 }
\cs_generate_variant:Nn \syllogism_make_text:n { V }
\ExplSyntaxOff

\NewDocumentCommand{\openparenref}{u\closeparenref}{\textup{(#1)}}
\NewDocumentCommand{\closeparenref}{}{}

\makeatletter
\newcounter{syllogism}
\renewcommand{\thesyllogism}{S\arabic{syllogism}\closeparenref}
\renewcommand{\p@syllogism}{\openparenref}
\newcounter{syllogismitem}
\renewcommand{\thesyllogismitem}{\Alph{syllogismitem}\closeparenref}
\renewcommand{\p@syllogismitem}{\openparenref S\arabic{syllogism}}
\makeatother

\begin{document}

\syllogism{
  number,
  label=syl1,
  subnumber,
  first-premiss={All men except Socrates are able to laugh\label{syl1A}},
  second-premiss={Socrates is a man\label{syl1B}},
  conclusion={Socrates is not able to laugh\label{syl1C}},
}

\bigskip

\syllogism{
  number,
  label=syl2,
  first-premiss={Mus syllaba est},
  second-premiss={Syllaba autem caseum non rodit},
  conclusion={Ergo mus caseum non rodit},
}

\bigskip

\syllogism{
  first-premiss={Mus syllaba est},
  second-premiss={Mus autem caseum rodit},
  conclusion={Ergo syllaba caseum rodit},
}

\bigskip

\syllogism{
  number,
  label=syl3,
  subnumber,
  first-premiss={
    All men except Socrates are able to laugh
    All men except Socrates are able to laugh
    All men except Socrates are able to laugh
    All men except Socrates are able to laugh\label{syl3A}
  },
  second-premiss={Socrates is a man\label{syl3B}},
  conclusion={Socrates is not able to laugh\label{syl3C}},
}

\bigskip

References:

\ref{syl1}--\ref{syl1A}--\ref{syl1B}--\ref{syl1C}

\ref{syl2}

\end{document}

enter image description here

  • Thank you. The approach of the syllogism package is not very convincing: why? Also how to get (S1)-(S1A)-(S1B).. instead of just S1-S1A-S1B...? I really need the brackets :-) – Furbenzio Feb 13 '16 at 14:02
  • 1
    @user82528 Define \newcommand{\sylref}[1]{\textup{(\ref{#1})}} and use \sylref instead of \ref. I looked at the macros and they seem much more complicated than necessary. – egreg Feb 13 '16 at 14:03
  • I know this is silly of me at least, but would it possible to keep the basic \refcommand? With the \sylref I end up losing the TeXmaker automatic completion while writing and this really slows things down.. – Furbenzio Feb 13 '16 at 14:13
  • 1
    @user82528 It's possible; check now – egreg Feb 13 '16 at 14:45
  • 1
    @user82528 Now they allow line breaks. Note that my macro doesn't produce overfull boxes, contrary to the original ones. ;-) – egreg Feb 13 '16 at 22:03

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.