1

I'm writing out proofs and I want to be able to show my work as follows

  1. Some function F(x) = blah

    1.1. Some operation on F(x) Some law or lemma

    1.2. Some other operation Justification

Where my bolded text represents text that's right justified. I want to have the operation I perform in a nested list environment (Some operation on F(x) and then the reasoning behind that operation to be right-justified.

I figured I could do this with enumerate and tabular, but I'm having alignment issues. Here's my MWE...

\documentclass[a4paper]{article}
\usepackage{enumitem}
% Use numbers when in plist (proof list)
\newlist{plist}{enumerate}{10}
\setlist[plist]{label*=\arabic*.}
\begin{document}
 % My main list
 \begin{plist}
   \item Lorem ipusm my function
   \begin{tabular}{p{.5\textwidth}r}
   \begin{plist}
     \item My function  %
   \end{plist}  
    & \textbf{Translation}\\
\end{tabular}
\end{plist}
\end{document}

The thing is, the alignment looks really off when the document is compiled (the line that says translation should be on the 1.1 line): Broken alignment

So here's what I'm wondering: How can I fix the alignment issues? Also: is it possible to have the right justified text all the way on the right side of the page (possible with tabularx) but I haven't figured out how to do that for right justified text. I've seen it used for left justified text that is also on the lefthand column, but I haven't been able to use it the other way around (the X column type, that is)

Thanks in advance :)

2 Answers2

1

Here is a solution with a short code found on this site:

\documentclass{article}
\usepackage{enumitem}
\usepackage{array} 

\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother

% Use numbers when in plist (proof list)
\newlist{plist}{enumerate}{10}
\setlist[plist]{label*=\arabic*.}

\begin{document}
 % My main list
 \begin{plist}
   \item Lorem ipusm my function

   \begin{tabular}{>{\compress}p{.5\textwidth}r}
   \begin{plist}
     \item My function %
   \end{plist}
    & \textbf{Translation}\\
\end{tabular}
\end{plist}

\end{document} 

enter image description here

Bernard
  • 271,350
  • Much better, this fixes the alignment but then the "translation" bit isn't tight against the right margin. Anywho thanks :) I can definitely work with this – BitShuffler May 19 '18 at 23:58
  • @Netwinder: If you want it against the right margin, use \begin{tabularx}{\linewidth}{>{\compress}Xr@{}}...\end{tabularx} – Bernard May 20 '18 at 00:07
  • While this is much more useful than what I had, is there a way to have the "translation" bit inside the plist (enumerate), so i can have multiple lines with multiple right-justified statements? – BitShuffler May 20 '18 at 00:23
0

In response to your comment you might be interested in the following approach, that wraps every single item into is own tabularx.

\documentclass{article}
\usepackage{tabularx}

\newcommand{\myitem}[2]{\item \begin{tabularx}{\linewidth}{@{}Xlr@{}} {#1} & \textbf{#2}  \end{tabularx}}

\begin{document}
\begin{enumerate}
\myitem{ some text}{text in bold}

\myitem{ome longer test that is broken over two lines}{and some longer bold text}

\item You can also use a normal item inbetween. This will use the whole linewidth to the right margin.
\end{enumerate}
\end{document}
leandriis
  • 62,593