2

I am using the tabularx environment to present formal arguments, and at the moment the left column is aligned with the left margin of the text and the right column is aligned with the right margin. For instance:

enter image description here

How can I get the left column to be aligned with the paragraph indent, but the right column to stay aligned with the right margin? I've tried using the changepage package and the \adjustwidth command but that doesn't seem to be helping, nor does adding \hspace{\parindent} in various places. I'm sure there's a really simple way to do it but I don't know how.

Here's a MWE:

\documentclass[12pt]{article}

\usepackage{tabularx} %tables
\usepackage{tabulary} %tables
\usepackage{lipsum}
\usepackage{upgreek} %greek letters
\usepackage{amssymb} %modal operators

\begin{document}

\lipsum[1-2]

\begin{table}[h!]
    \centering
    \setlength{\extrarowheight}{3pt}
    \begin{tabularx}{\textwidth}{@{}rXr@{}}
        (1) & $\varnothing \vdash \pi \leftrightarrow val(\ulcorner \pi \urcorner, \ulcorner \bot \urcorner)$ & ($\pi$ def.)\\
        (2) & $\pi \vdash \pi$ & (Assumption)\\
        (3) & $\pi \vdash val(\ulcorner \pi \urcorner, \ulcorner \bot \urcorner)$ & (1,2, MP)\\
        (4) & $\pi \vdash \bot$ & (2,3, \textit{V-Detach})\\
        (5) & $\varnothing \vdash val(\ulcorner \pi \urcorner, \ulcorner \bot \urcorner)$ & (4, \textit{V-Schema})\\
        (6) & $\varnothing \vdash \pi$ & (1,5, MP)\\
        (7) & $\varnothing \vdash \bot$ & (5,6, \textit{V-Detach})\\
    \end{tabularx}
\end{table}

\lipsum[3-4]


\end{document}

Thanks!

2
  • Please clarify what you mean by "How can I get the left column to be aligned with the paragraph indent". E.g., do you wish the tabularx environment to have width \textwidth-\parindent? Please advise.
    – Mico
    Sep 13, 2020 at 16:23
  • I would like the list of numbers in the table to be aligned with the paragraph indents in the ordinary text. So the numbers should be aligned with the word 'Nulla' in the image above. Hope that clarifies. Sep 13, 2020 at 16:27

2 Answers 2

5

The default value of \parindent in the article document class is 1.5em. To achieve your formatting objective, it therefore suffices to change

\begin{tabularx}{\textwidth}{@{} rXr @{}}

to

\begin{tabularx}{\textwidth}{@{\hspace{1.5em}} rXr @{}}

Since the overall usable width of the tabularx environment is decreased by 1.5em, LaTeX will automatically decrease the width of the X colum by that amount in order to assure that it will continue to fit inside the textblock.


Addendum: In case you don't happen to know the value of \parindent, you could execute, say,

\newlength\origparindent
\setlength{\origparindent}{\parindent}

sometime before starting the table environment and replace

\begin{tabularx}{\textwidth}{@{\hspace{1.5em}} rXr @{}}

with

\begin{tabularx}{\textwidth}{@{\hspace{\origparindent}} rXr @{}}
5
  • 1
    Uh! Why not \hspace{\parindent}?
    – egreg
    Sep 13, 2020 at 19:33
  • 1
    @egreg - Because \parindent is set to 0pt inside table and figure floats.
    – Mico
    Sep 13, 2020 at 19:43
  • But the first thing to remove here is the table environment! The OP uses h! in the (vain) hope that the table would really end “here”. If the object is a float there is no need to respect the indentation.
    – egreg
    Sep 13, 2020 at 19:58
  • Anyway, you don't need such esoteric \the\parindent: just do \newlength{\normalparindent}\AtBeginDocument{\setlength{\normalparindent}{\parindent}} and use \normalparindent where \parindent may be set to a different value.
    – egreg
    Sep 13, 2020 at 20:06
  • @egreg - Thanks for the pointer (reminder?!) that \setlength{\origparindent}{\parindent} works just fine.
    – Mico
    Sep 13, 2020 at 20:34
4

You don't need to know the value of \parindent, because TeX knows it.

Also you don't want a table environment, because it's a floating object and you quite likely want the material there, not somewhere else.

You can use an enumerate environment, properly set up with the help of enumitem. Pushing something to the right margin is easy with \hfill, so long as the preceding material allows for the placement, more precisely it wouldn't overlap the label.

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage{upgreek} %greek letters
\usepackage{amssymb} %modal operators
\usepackage{enumitem}

\newenvironment{sidecond}
 {\begin{enumerate}[
    label=(\arabic*),
    leftmargin=\dimexpr\parindent+\labelsep,
    labelwidth=0pt,
    align=left
]}
{\end{enumerate}}

\begin{document}

\lipsum[2][1-5]

\begin{sidecond}
\item $\varnothing \vdash \pi \leftrightarrow 
       \mathit{val}(\ulcorner \pi \urcorner, \ulcorner \bot \urcorner)$\hfill ($\pi$ def.)

\item $\pi \vdash \pi$\hfill (Assumption)

\item $\pi \vdash \mathit{val}(\ulcorner \pi \urcorner, \ulcorner \bot \urcorner)$\hfill (1,2, MP)

\item $\pi \vdash \bot$\hfill (2,3, \textit{V-Detach})

\item $\varnothing \vdash \mathit{val}(\ulcorner \pi \urcorner, \ulcorner \bot \urcorner)$\hfill
      (4, \textit{V-Schema})

\item $\varnothing \vdash \pi$\hfill (1,5, MP)

\item $\varnothing \vdash \bot$\hfill (5,6, \textit{V-Detach})
\end{sidecond}

\lipsum[4][1-3]


\end{document}

enter image description here

A couple of final notes. I used \mathit{val}, because otherwise the letters are too spaced out (because they denote the product of three variables). I left \varnothing even if I abhor it for denoting the empty set.

1
  • +1. :-) Another advantage of using an enumerate environment (instead of a tabularx environment as in the OP's setup) is that a page break inside the list is entirely possible.
    – Mico
    Sep 13, 2020 at 20:37

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.