Text FormattingBullets (itemized) INSIDE A TabularX Cell

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
InquisitorMo
Posts: 44
Joined: Mon Jul 15, 2013 12:22 am

Bullets (itemized) INSIDE A TabularX Cell

Post by InquisitorMo »

I'm not sure how to use the <{ and the >{ commands to do that, but it sounds like what I want to do - have a column of bullets...
---

This however does NOT COMPILE
% I am trying to 'open' the itemize environment' with the margin parameters I gave it... but I'm pretty sure I'm doing this wrong.

I then try to open and close the itemize environment for every bullet I want (which is annoying, but worked in the simpler table I used above)...

Any suggestions?

Code: Select all

\documentclass{article}

\usepackage{paralist}
\usepackage{tabularx}
\usepackage{enumitem}

\begin{document}

\newcolumntype{R}{>{\raggedleft\arraybackslash}X}%
\begin{tabularx}{\textwidth}{ | p{2in} | p{2in} | R | } 

%\begin{tabularx}{\textwidth}{l l l}

%\begin{tabularx}{\textwidth}{| p{6cm} | p{2cm} |}

\begin{itemize}[leftmargin=10pt, labelindent=0pt, itemindent=0pt]


 \item The bullet is here... \end{itemize} & \item I want the bullet without any space above it like here \end{itemize} & {}\\
 
\begin{itemize}\item more text on this line\end{itemize} & {more text in this column} & {}\\

\end{tabularx}

\end{document}

%\end{itemize}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10346
Joined: Mon Mar 10, 2008 9:44 pm

Bullets (itemized) INSIDE A TabularX Cell

Post by Stefan Kottwitz »

You forgot a \begin{itemize}. Here I inserted it and it works:

Code: Select all

\documentclass{article}

\usepackage{paralist}
\usepackage{tabularx}
\usepackage{enumitem}

\begin{document}

\newcolumntype{R}{>{\raggedleft\arraybackslash}X}%
\begin{tabularx}{\textwidth}{ | p{2in} | p{2in} | R | }

%\begin{tabularx}{\textwidth}{l l l}

%\begin{tabularx}{\textwidth}{| p{6cm} | p{2cm} |}

\begin{itemize}[leftmargin=10pt, labelindent=0pt, itemindent=0pt]


 \item The bullet is here... \end{itemize} & \begin{itemize}[leftmargin=10pt, labelindent=0pt, itemindent=0pt]\item I want the bullet without any space above it like here \end{itemize} & {}\\
 
\begin{itemize}\item more text on this line\end{itemize} & {more text in this column} & {}\\

\end{tabularx}

\end{document}
You may understand, that we can spot such mistakes only if we can see the code.

For this example I made a new column style for itemize cells:

Code: Select all

\documentclass{article}

\usepackage{paralist}
\usepackage{tabularx}
\usepackage{enumitem}

\newcolumntype{R}{>{\raggedleft\arraybackslash}X}%
\newcolumntype{I}[1]{>{\begin{itemize}[leftmargin=10pt, labelindent=0pt,
  itemindent=0pt]}p{#1}<{\end{itemize}}}
\begin{document}

\begin{tabularx}{\textwidth}{ | I{2in} | I{2in} | R | }
\item The bullet is here...  & \item I want the bullet without any space above it like here & {}\\
\item more text on this line & \item[] more text in this column & {}\\
\end{tabularx}

\end{document}
Btw. if you would like to have only one bullet in each cell instead of a whole list, it would be much easier of course.

Stefan
LaTeX.org admin
InquisitorMo
Posts: 44
Joined: Mon Jul 15, 2013 12:22 am

Bullets (itemized) INSIDE A TabularX Cell

Post by InquisitorMo »

Yes!!! That is it! Thank you so much!!! :)

* I have now tried substituting 'compactitem' for where you have 'itemize' in the second code (redefined table example) example above, and it compiles, but it doesn't change anything.

I am trying to get the bullets on successive lines, so no spaces. I am also of course trying to remove any space above or below the bullets, basically so it's just regular text line by line, but with bullets.

There are many solutions on the forums for this involving other packages, and also just using a manual minus to move the spaces, but I can't figure out how why there's such a large space between the bullets to begin with when there's nothing in the code to indicate that?

Code: Select all

\documentclass{article}

\usepackage{paralist}
\usepackage{tabularx}
\usepackage{enumitem}

\newcolumntype{R}{>{\raggedleft\arraybackslash}X}%
\newcolumntype{I}[1]{>{\begin{compactitem}}p{#1}<{\end{compactitem}}}
\begin{document}

\begin{tabularx}{\textwidth}{ | I{2in} | I{2in} | R | }
\item The bullet is here...  & \item I want the bullet without any space above it like here & {}\\
\item more text on this line & \item[] more text in this column & {}\\
\end{tabularx}

\end{document}
InquisitorMo
Posts: 44
Joined: Mon Jul 15, 2013 12:22 am

Bullets (itemized) INSIDE A TabularX Cell

Post by InquisitorMo »

I tried using the "itemsep=5pt" parameter I read about someone using in enumitem, but for some reason it doesn't work here (and it also does not work in the first example, where the new column type wasn't used either).

Code: Select all

\documentclass{article}

\usepackage{paralist}
\usepackage{tabularx}
\usepackage{enumitem}

\newcolumntype{R}{>{\raggedleft\arraybackslash}X}%
\newcolumntype{I}[1]{>{\begin{itemize}[itemsep=5pt, parsep=5pt, leftmargin=10pt, labelindent=0pt,
  itemindent=0pt]}p{#1}<{\end{itemize}}}
\begin{document}

\begin{tabularx}{\textwidth}{ | I{2in} | I{2in} | R | }
\item The bullet is here...  & \item I want the bullet without any space above it like here & {}\\
\item more text on this line & \item[] more text in this column & {}\\
\end{tabularx}

\end{document}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10346
Joined: Mon Mar 10, 2008 9:44 pm

Bullets (itemized) INSIDE A TabularX Cell

Post by Stefan Kottwitz »

itemize lists don't take so much space at the beginning of a page or a minipage. We can use this and also could add another correction at the end.

This would be without space before and after:

Code: Select all

\makeatletter
\newcolumntype{I}[1]{>{%
  \@minipagetrue\begin{compactitem}}p{#1}<{\end{compactitem}\vspace{-\baselineskip}}}
\makeatother
table-itemize.png
table-itemize.png (4.24 KiB) Viewed 10283 times
Stefan
LaTeX.org admin
InquisitorMo
Posts: 44
Joined: Mon Jul 15, 2013 12:22 am

Bullets (itemized) INSIDE A TabularX Cell

Post by InquisitorMo »

Ok I tried it a 3rd way (the first two above, sorry for so many posts), and I thought I was really close to getting it after I found this example online:

http://alvinalexander.com/blog/post/lat ... erate-tags

***But for some reason it's still not working!

*** I do think this is probably the 'easiest' solution if I can get it to work, as it just creates a new environment with itemize...

Code: Select all

\documentclass{article}

\usepackage{paralist}
\usepackage{tabularx}
\usepackage{enumitem}

\newenvironment{packed_item}{
\begin{itemize}
  \setlength{\itemsep}{1pt}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}
}{\end{itemize}}


\begin{document}

\newcolumntype{R}{>{\raggedleft\arraybackslash}X}%
\begin{tabularx}{\textwidth}{ | p{2in} | p{2in} | R | }

%\begin{tabularx}{\textwidth}{l l l}

%\begin{tabularx}{\textwidth}{| p{6cm} | p{2cm} |}

\begin{packed_item} %[itemsep=5pt, parsep=5pt, leftmargin=10pt, labelindent=0pt, itemindent=0pt]


 \item The bullet is here... \end{packed_item} & \begin{packed_item}\item I want the bullet without any space above it like here \end{packed_item} & {}\\
 
\begin{packed_item}
\item more text on this line\end{packed_item} & {more text in this column} & {}\\

\end{tabularx}

\end{document}
InquisitorMo
Posts: 44
Joined: Mon Jul 15, 2013 12:22 am

Bullets (itemized) INSIDE A TabularX Cell

Post by InquisitorMo »

Sorry posted that before the page updated - didn't see your reply!

*Definitely getting much closer - I've used your last instructions (though I'm still interested in figuring out how to use the 'environment' example as it seems cleaner), to get this:

*It's annoying that the bullets skip lines based on the other column (instead of just condensing bullets INSIDE the column independent of the other column), but in my case I'm going to ignore it since I only need bullets in one column.


Code: Select all

\documentclass{article}

\usepackage{paralist}
\usepackage{tabularx}
\usepackage{enumitem}


\makeatletter
\newcolumntype{I}[1]{>{\@minipagetrue\begin{compactitem}}p{#1}<{\end{compactitem}\vspace{-\baselineskip}}}
\makeatother

\newcolumntype{R}{>{\raggedleft\arraybackslash}X}%
%\newcolumntype{I}[1]{>{\begin{compactitem}}p{#1}<{\end{compactitem}}}

\begin{document}

\begin{tabularx}{\textwidth}{ | I{2in} | I{2in} | R | }
\item The bullet is here...  & \item ace above it like here & {}\\
\item more text on this line & \item[] more text in this column & {}\\
\item test & \item test & testttttttt\\
\end{tabularx}

\end{document}
Screen Shot 2013-07-22 at 5.53.12 PM.png
Screen Shot 2013-07-22 at 5.53.12 PM.png (26.07 KiB) Viewed 10272 times
Last edited by cgnieder on Tue Jul 23, 2013 2:12 pm, edited 1 time in total.
InquisitorMo
Posts: 44
Joined: Mon Jul 15, 2013 12:22 am

Bullets (itemized) INSIDE A TabularX Cell

Post by InquisitorMo »

Closer still! I am having trouble adding multiple parameters to my new column though - the below will not compile:

I want the new column "I" to be defined as 'ragged right' AND also run the {packed_enum} environment. I got it to work without ragged right and it was great, so I'm just trying to add the margin part as I did in the new column "R" that I define right above it.

I read the array package, but can't figure out how to add multiple parameters together when I create a new column?


Code: Select all

\documentclass[letterpaper,11pt]{report}

\usepackage{tabularx}
\usepackage{enumitem}

\setitemize{noitemsep, topsep=0pt, parsep=0pt}

\newenvironment{packed_enum}{
\begin{itemize}
  \setlength{\itemsep}{1pt}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}
}{\end{itemize}}

\newcolumntype{R}{>{\raggedleft\arraybackslash}X}%
\newcolumntype{I}[1]{>{\raggedright\arraybackslash}X}<{\begin{packed_enum}p{#1}{\end{packed_enum}}%

\begin{document}

\chapter{Movies I need to watch}

Here is a short list of movies I need to watch some day:\\


\begin{tabularx}{\textwidth}{X | I{2in} }

{Here is text that is NOT bulleted appearing on the FIRST line... } & \item This bulleted text though still skips a line, but I think that's ok since it offsets the bulleted list \item The Longest Day \item The Longest Day \item The Longest Day\\
{} & \item Test new line

\end{tabularx}
\end{document}
InquisitorMo
Posts: 44
Joined: Mon Jul 15, 2013 12:22 am

Bullets (itemized) INSIDE A TabularX Cell

Post by InquisitorMo »

I fixed it!!!

Reading through the array documentation was very confusing - it doesn't explain well how to feed parameters to a new column type, which I presume is just a standard understanding of Latex which I don't have..

This was the line that gave me all the trouble, step by step, my (mis)understanding:

\newcolumntype{I}[1]{>{\begin{packed_enum}\raggedright\arraybackslash}p{#1}<{\end{packed_enum}}}

1. I don't know what the [1] is for, but I know that > is a command executed before the table cell, so I wanted it to apply my previously defined "packed_enum" (should be renamed to packed_item for clarity)...

2. BUT then I didn't know how to concatenate a second parameter, namely the margin formatting, so I tried just adding it straight after "\raggedright\arraybackslash" and closing up with brackets. This worked!!!

3. I then, also don't know what the p{#1} is for, or why it's placed in the syntax there... just copying what you wrote for me there...

4. I then know that < is the command executed AFTER the table cell, so I wanted it to close out my 'packed_enum' which I do, and then bracket the whole thing.

5. The result is I have a column formatted to run my own itemize environment upon using the \item command inside the table, (with no spaces between bullets and the bullet placement formatting I want previously defined), ALSO with a ragged right margin for the column margin itself.

THAT was very difficult for me, despite its seemingly innocuous appearance. I think I can work this into my CV now.

If you have any other comments, I'd love the learning experience. Otherwise, THANK YOU SO MUCH for the help!

Code: Select all

\documentclass[letterpaper,11pt]{report}

\usepackage{tabularx}
\usepackage{enumitem}

%\setitemize{noitemsep, topsep=0pt, parsep=0pt}

\newenvironment{packed_enum}{
\begin{itemize}
  \setlength{\itemsep}{1pt}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}
}{\end{itemize}}


\newcolumntype{R}{>{\raggedleft\arraybackslash}X}%

\newcolumntype{I}[1]{>{\begin{packed_enum}\raggedright\arraybackslash}p{#1}<{\end{packed_enum}}}%

\begin{document}

\chapter{Movies I need to watch}

Here is a short list of movies I need to watch some day:\\


\begin{tabularx}{\textwidth}{X | I{2in} }

{Here is text that is NOT bulleted appearing on the FIRST line... } & \item This bulleted text though still skips a line, but I think that's ok since it offsets the bulleted list \item The Longest Day \item The Longest Day \item The Longest Day\\
{} & \item Test new line

\end{tabularx}
\end{document}
InquisitorMo
Posts: 44
Joined: Mon Jul 15, 2013 12:22 am

Re: Bullets (itemized) INSIDE A TabularX Cell

Post by InquisitorMo »

The Output:
Attachments
Screen Shot 2013-07-22 at 8.56.27 PM.png
Screen Shot 2013-07-22 at 8.56.27 PM.png (130.5 KiB) Viewed 10280 times
Post Reply