4 ms·
Latex is better than its competitors (Word, OpenOffice), but it has its problems. Many of the environments are fragile and not composable. Last night, I was try
by scott_s 17y ago
Latex is better than its competitors (Word, OpenOffice), but it has its problems. Many of the environments are fragile and not composable. Last night, I was trying to embed a list inside a table.
I had this, and the problem was that the longer item does not wordwrap:
\begin{tabular}{|l|l|}
\hline
\textbf{Title A} & thing 1 \\
& thing 2, but it's much longer than the other items \\
& thing 3 \\
\hline
\textbf{Title B} & thing 1 \\
& thing 2, but it's much longer than the other items \\
& thing 3 \\
\hline
\textbf{Title C} & thing 1 \\
& thing 2, but it's much longer than the other items \\
& thing 3 \\
\hline
\end{tabular}
The items on the right are not a list. However, you can not embed an itemize environment in a tabular environment. Further, this table does no word wrapping. I wanted an itemized, bulleted list on the right, so 30 minutes of Googling and experimenting later, I have a solution using the tabularx package:
\begin{tabularx}{0.9\linewidth}{|l|X|}
\hline
\textbf{Title A} & \begin{itemize}
\item thing 1
\item thing 2, but it's much longer than the other items
\item thing 3
\end{itemize} \\
\hline
\textbf{Title B} & \begin{itemize}
\item thing 1
\item thing 2, but it's much longer than the other items
\item thing 3
\end{itemize} \\
\hline
\textbf{Title C} & \begin{itemize}
\item thing 1
\item thing 2, but it's much longer than the other items
\item thing 3
\end{itemize} \\
\hline
\end{tabularx}
This does as advertised. I get a word wrapped, bulleted list on the right. It's also fugly. The spacing of the list is atrocious. It's not fit for a professional publication. Eventually, I end up rolling my own bulleted list:
\begin{tabularx}{0.9\linewidth}{|l|X|}
\hline
\textbf{Title A} &
$\bullet$ thing 1 \newline
$\bullet$ thing 2, but it's much longer than the other items \newline
$\bullet$ thing 3 \newline
\hline
\textbf{Title B} &
$\bullet$ thing 1 \newline
$\bullet$ thing 2, but it's much longer than the other items \newline
$\bullet$ thing 3 \newline
\hline
\textbf{Title C} &
$\bullet$ thing 1 \newline
$\bullet$ thing 2, but it's much longer than the other itmes \newline
$\bullet$ thing 3 \newline
\hline
\end{tabularx}
Finally, this looks okay. But the road it took to get here is ridiculous, and the solution I came up with is silly. (Also note that I had to use \newline, because the end paragraph maker, \\, would screw up the table.)
In the end, I like Latex. It is, as I said, better than the alternatives. When what you want to do fits exactly into what's provided, it's fine. But when you hit edge cases, abstractions leak and you can sink hours into fixing things. I would love there to be a version of Latex that was not fragile like this.
- dmlorenzetti 17y agoThis is a shot in the dark, but have you tried inserting a \parbox or minipage environment into the table? I solved this problem in the past, much more simply. I think I embedded a \vbox in the table (back when I used TeX rather than LaTeX). Sorry I can't be more specific-- I poked around on the hard drive of my current machine, and didn't find it, so this must have been many years ago, on a project that didn't merit copying over.
- scott_s 17y agoNope, but it very well could work. The solution I did come up, though, also works. But this is all part of my larger point: Latex can be fragile, and getting it to do what you want is often nonobvious.
- Quiark 17y agoMaybe you could try ConTeXt. I don't know if it has this problem though.
- scott_s 17y agoI had never heard of it before: http://wiki.contextgarden.net/Main_Page http://wiki.contextgarden.net/Main_Page I'm not sure if it's what I need, but thanks for pointing it out. It's nice to know people are exploring typesetting/document composition environments that build on Tex, but are not Latex.
- scott_s 17y agoDamn, I can't edit this any longer. Just in case this pops up on Google for a decent way to achieve this, my last Latex example is missing needed \\ commands. It should be: \begin{tabularx}{0.9\linewidth}{|l|X|} \hline \textbf{Title A} & $\bullet$ thing 1 \newline $\bullet$ thing 2, but it's much longer than the other items \newline $\bullet$ thing 3 \\ \hline \textbf{Title B} & $\bullet$ thing 1 \newline $\bullet$ thing 2, but it's much longer than the other items \newline $\bullet$ thing 3 \\ \hline \textbf{Title C} & $\bullet$ thing 1 \newline $\bullet$ thing 2, but it's much longer than the other itmes \newline $\bullet$ thing 3 \\ \hline \end{tabularx}