我正在尝试创建一个 tabularx 环境,它将像图片中那样对齐两列表格,但我希望右侧的文本以一定的宽度换行。
我做了什么:我尝试使用w{align}{width}
来设置对齐方式和宽度。但在这里,“宽度”似乎是单元格本身的宽度,与单元格内的文本无关。我尝试过,\newcolumntype
我认为答案就在这里,但我无法理解它的工作原理。“声明”没有意义。
我正在寻找的行为类似于同时p{#cm}
仍能控制左对齐。你能帮助 LaTeX 新手吗?:)
梅威瑟:
\documentclass[tikz]{standalone}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tabularx}
\setlength{\tabcolsep}{3pt}
\renewcommand{\arraystretch}{0.3}
\begin{document}
\hspace{3cm}
\vspace{3cm}
\begin{tabularx}{\textwidth}{rl}
\color{black}\textbf{\scalebox{0.5}{decision}} & \color{black}\textbf{\scalebox{0.5}{this is some text meant to be very long so I would have to wrap it. It's a puzzling experience.}} \\
\color{black}\textbf{\scalebox{0.5}{decisions, decisions}} & \color{black}\textbf{\scalebox{0.5}{this is some text meant to be very long so I would have to wrap it. It's a puzzling experience.}} \\
\color{black}\textbf{\scalebox{0.5}{decisions, decisions, decisions}} & \color{black}\textbf{\scalebox{0.5}{this is some text meant to be very long so I would have to wrap it. It's a puzzling experience.}} \\
\color{black}\textbf{\scalebox{0.5}{decision}} & \color{black}\textbf{\scalebox{0.5}{this is some text meant to be very long so I would have to wrap it. It's a puzzling experience.}} \\
\color{black}\textbf{\scalebox{0.5}{decision}} & \color{black}\textbf{\scalebox{0.5}{this is some text meant to be very long so I would have to wrap it. It's a puzzling experience.}} \\
\color{black}\textbf{\scalebox{0.5}{decision}} & \color{black}\textbf{\scalebox{0.5}{this is some text meant to be very long so I would have to wrap it. It's a puzzling experience.}} \\
\color{black}\textbf{\scalebox{0.5}{decision}} & \color{black}\textbf{\scalebox{0.5}{this is some text meant to be very long so I would have to wrap it. It's a puzzling experience.}} \\
\color{black}\textbf{\scalebox{0.5}{decision}} & \color{black}\textbf{\scalebox{0.5}{this is some text meant to be very long so I would have to wrap it. It's a puzzling experience.}} \\
\end{tabularx}
\end{document}
答案1
像这样?
\documentclass{article}
\usepackage{lmodern}
\usepackage{tabularx}
% smaller font size: https://tex.stackexchange.com/a/57676/201158
\newcolumntype{Y}{>{\raggedleft\arraybackslash\fontsize{2.5}{4}\selectfont}X}
\newcolumntype{P}[1]{>{\fontsize{4}{2}\selectfont}p{#1}}
\newcommand\test[1]{
\noindent
\begin{tabularx}{\linewidth}{YP{#1\linewidth}}
decision & this is some text meant to be very long so I would have to wrap it. It's a puzzling experience. \\
decisions, decisions & this is some text meant to be very long so I would have to wrap it. It's a puzzling experience. \\
decisions, decisions, decisions & this is some text meant to be very long so I would have to wrap it. It's a puzzling experience. \\
\end{tabularx}\par\vspace{1em}
}
\begin{document}
\test{.8}
\test{.7}
\test{.6}
\end{document}