# Align text vertically in easylist

My MWE:

\documentclass{article}
\usepackage{amssymb}
\usepackage[ampersand]{easylist}
\usepackage{changepage}
\usepackage{lipsum}

\usepackage{amssymb}
\usepackage[ampersand]{easylist}

\begin{document}
\begin{easylist}
& 1 Align this text vertically
& 20 Align this text vertically
& 300 Align this text vertically
& 4000 Align this text vertically
& 50000 Align this text vertically
\end{easylist}
\end{document}


Is it possible to make desired output with some easy commands. \tab or something like that?

## 1 Answer

I'd use a tabular for this. Below defines you the environments Enumtable, Itemtable, and Desctable which should work similar to enumerate, itemize, and description, respectively, but the current implementation is not really nestable and doesn't use the global definition which symbols to use and stuff. If those features are needed, I could add them.

\documentclass[]{article}

\usepackage{array}
\usepackage{xparse}
\usepackage{collcell}

\makeatletter
\newcolumntype{\ListtableColumn}[1]
{>{\collectcell\Listtable@Item}#1<{\endcollectcell}}
\newcounter{Listtable@counter}
\NewDocumentEnvironment{Enumtable}{ O{} D(){l} m }
{%
\renewcommand*\theListtable@counter{\arabic{Listtable@counter}.}%
\def\Listtable@Item##1%
{%
\stepcounter{Listtable@counter}%
\theListtable@counter
\if\relax\detokenize{##1}\relax
\else
\ ##1%
\fi
}%
\begin{tabular}[#1]{\ListtableColumn{#2} #3}
}
{%
\end{tabular}%
}
\NewDocumentEnvironment{Itemtable}{ O{} D(){l} m }
{%
\def\Listtable@Item##1%
{%
$\bullet$%
\if\relax\detokenize{##1}\relax
\else
\ ##1%
\fi
}%
\begin{tabular}[#1]{\ListtableColumn{#2} #3}
}
{%
\end{tabular}%
}
\NewDocumentEnvironment{Desctable}{ O{} D(){l} m }
{%
\def\Listtable@Item##1%
{%
\if\relax\detokenize{##1}\relax
\else
\textbf{##1}%
\fi
}%
\begin{tabular}[#1]{\ListtableColumn{#2} #3}
}
{%
\end{tabular}%
}
\makeatother

\begin{document}
\begin{Enumtable}{l}
1     & Align this text vertically\\
20    & Align this text vertically\\
300   & Align this text vertically\\
4000  & Align this text vertically\\
50000 & Align this text vertically\\
\end{Enumtable}

\begin{Itemtable}{l}
1     & Align this text vertically\\
20    & Align this text vertically\\
300   & Align this text vertically\\
4000  & Align this text vertically\\
50000 & Align this text vertically\\
\end{Itemtable}

\begin{Desctable}{l}
1     & Align this text vertically\\
20    & Align this text vertically\\
300   & Align this text vertically\\
4000  & Align this text vertically\\
50000 & Align this text vertically\\
\end{Desctable}
\end{document}


Output:

Edit: Nestable version. Page breakable with longtable doesn't seem to work with the current code, as well as fixed width with tabularx. I guess one would need a different approach if that was required.

\documentclass[]{article}

\usepackage{array}
\usepackage{xparse}
\usepackage{collcell}
\usepackage{amssymb}
\usepackage{etoolbox}

\usepackage{duckuments}% just for dummy content

\makeatletter
\newcolumntype{\ListtableColumn}[1]
{>{\collectcell\Listtable@Item}#1<{\endcollectcell}}
\newcounter{Listtable@counter}
\newbox\Listtable@box
\def\Listtable@Item#1{}
\def\Listtable@precounter{}
\renewcommand*\theListtable@counter{}
\newcount\Listtable@layer
\newcommand*\Listtable@itemsep{\hspace{.25cm}}
% extra space if first column has contents in Enumtable or Itemtable
\newcommand*\Listtable@addedspace{\hspace*{.25cm}}
\newcommand*\Listtable@leftskip
{\hspace{\csname Listtable@leftskip@\@alph\Listtable@layer\endcsname}}
\newcommand*\Listtable@leftskip@a{.5cm}
\newcommand*\Listtable@leftskip@b{1cm}
\newcommand*\Listtable@leftskip@c{1.5cm}
\newcommand*\Listtable@leftskip@d{2cm}
\newcommand*\Listtable@item
{\csname Listtable@item@\@alph\Listtable@layer\endcsname}
\newcommand*\Listtable@item@a{$\bullet$}
\newcommand*\Listtable@item@b{$\circ$}
\newcommand*\Listtable@item@c{\begingroup\tiny$\blacksquare$\endgroup}
\newcommand*\Listtable@item@d{\begingroup\tiny$\square$\endgroup}
\newcommand*\Listtable@AfterEnvironment{}
\NewDocumentEnvironment{Listtable}{ O{} m m }%>>>
{%
\begin{tabular}[#1]
{%
@{\Listtable@leftskip} \ListtableColumn{#2} @{\Listtable@itemsep} #3
}%
}
{%
\end{tabular}%
}%<<<
\NewDocumentCommand \Listtable@define { m m m m }%>>>
{%
\NewDocumentEnvironment {#1} { O{} D(){l} m }
{%
\advance\Listtable@layer\@ne
\ifnum\Listtable@layer=\@ne
\par\medskip\noindent
\fi
#2%
\renewcommand\Listtable@Item[1]
{%
#3%
}%
\global\setbox\Listtable@box\hbox\bgroup
\begin{Listtable}[##1]{##2}{##3}%
}
{%
\end{Listtable}%
\egroup
#4
\ifnum\Listtable@layer=\@ne
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
{%
\unhbox\Listtable@box
\par\medskip
}%
{%
\ifhmode\unskip\fi
\gdef\Listtable@AfterEnvironment
{%
\\\noalign
{%
\unhbox\Listtable@box
\gdef\Listtable@AfterEnvironment{}%
\ignorespaces
}%
}%
}%
}%
\AfterEndEnvironment{#1}{\Listtable@AfterEnvironment}%
}%<<<
\Listtable@define{Enumtable}%>>>
{%
\edef\Listtable@savecounter{\the\c@Listtable@counter}%
\edef\Listtable@precounter{\theListtable@counter}%
\setcounter{Listtable@counter}{0}%
\renewcommand*\theListtable@counter
{\Listtable@precounter\arabic{Listtable@counter}.}%
}
{%
\stepcounter{Listtable@counter}%
\theListtable@counter
\if\relax\detokenize{##1}\relax
\else
\Listtable@itemsep ##1\Listtable@addedspace
\fi
}
{%
\setcounter{Listtable@counter}{\Listtable@savecounter}%
}%<<<
\Listtable@define{Itemtable}{}%>>>
{%
\Listtable@item
\if\relax\detokenize{##1}\relax
\else
\Listtable@itemsep ##1\Listtable@addedspace
\fi
}
{}%<<<
\Listtable@define{Desctable}{}%>>>
{%
\if\relax\detokenize{##1}\relax
\else
\textbf{##1}%
\fi
}
{}%<<<
\makeatother

\begin{document}
\blindduck
\begin{Enumtable}{l}
1     & Align this text vertically
\begin{Enumtable}{l}
& second layer test
\begin{Enumtable}{l}
& third layer test
\begin{Enumtable}{l}
& fourth layer test\\
& fourth layer test\\
\end{Enumtable}
& third layer test\\
\end{Enumtable}
& second layer test\\
\end{Enumtable}
20    & Align this text vertically\\
300   & Align this text vertically\\
4000  & Align this text vertically\\
50000 & Align this text vertically\\
\end{Enumtable}

\begin{Itemtable}{l}
1     & Align this text vertically
\begin{Itemtable}{l}
& second layer test
\begin{Itemtable}{l}
& third layer test
\begin{Itemtable}{l}
& fourth layer test\\
& fourth layer test\\
\end{Itemtable}
& third layer test\\
\end{Itemtable}
& second layer test\\
\end{Itemtable}
20    & Align this text vertically\\
300   & Align this text vertically\\
4000  & Align this text vertically\\
50000 & Align this text vertically\\
\end{Itemtable}

\begin{Desctable}{l}
1     & Align this text vertically
\begin{Desctable}{l}
second & layer test
\begin{Desctable}{l}
third & layer test
\begin{Desctable}{l}
fourth & layer test\\
fourth & layer test
\end{Desctable}
third & layer test\\
\end{Desctable}
second & layer test\\
\end{Desctable}
20    & Align this text vertically\\
300   & Align this text vertically\\
4000  & Align this text vertically\\
50000 & Align this text vertically\\
\end{Desctable}
\end{document}


• This is veryvery good!! Can you please make nestable and to choose which symbols to use and if you can determine something like this: ibb.co/k54JpJ 0.5cm is indent for 1st level bullet, 0.25cm is spacing between bullet and text, and 1cm is progressive indentation between levels. Iam asking you this because your solution is 10x better than using easylist. – Beginner Jul 21 '18 at 10:36
• @Beginner it has the drawback of not being page breakable (if you consider this a drawback). I'll make the required edits. Using longtable I could create a version that is page breakable. – Skillmon Jul 21 '18 at 11:23
• Yea, I would like that I can make pagebreak. Btw I appreciate your work, thank you in advance! You are making it very easy because with single function\begin{functionName} text \end{functionName} I can have table + bullet list within plus with function of nesting and changing bullet style. – Beginner Jul 21 '18 at 11:33
• thanks for update, is it possible to make shorter code for when changing bullet level. Instead of writing again for example \begin{Desctable} just some symbol like in easylist only &. Please. :) – Beginner Jul 22 '18 at 11:54
• @Beginner would not advise this, because & is the alignment character in a table like environment. I don't think I'll further develop the code in this answer, as the code seems very unstable (in respect to changes), perhaps I'll try with a different approach. The nesting is done similar to normal list environments (but you have to not use \\  prior to the nested list). – Skillmon Jul 22 '18 at 12:06