如何在乳胶中使用Tabularx时在单元格内换行?

问题描述 投票:0回答:1

enter image description here

\begin{tabularx}{\textwidth}{|c|X|X|c|}

\hline
S.no & \multicolumn{1}{|c|}{\textbf{headline}} & \multicolumn{1}{|c|}{\textbf{article\_link}} & \bf\Centering is\_sarcastic \\ \hline
1 &
  man who said 'yes' to life found with mountain bike at bottom of gorge &
  {https://local.theonion.com/man-who-said-yes-to-life-found-with-mountain-bike-at-bo-1819573183} &
  1\\
\hline 
2 &
  tina fey is worried about what the internet is doing to society &
  {https://www.huffingtonpost.com/entry/tina-fey-internet\_us\_5848252ce4b08c82e888ff80} &
  0 \\
\hline 
3 &
  why a woman refuses to leave her husband who threatened to kill her &
  {https://www.huffingtonpost.com/entry/pro-fighter-allegedly-abuses-wife\_n\_6072618.html} &
  0 \\ \hline
\end{tabularx}
latex
1个回答
0
投票
  • 不要将网址写为文本。有urlhyperref之类的程序包,它们为它们提供了专用的\url{}

  • 为了使更多可能的断点挤入您的收窄列中,请尝试使用xurl程序包

  • 切勿使用\bf之类的两个字母的字体命令,不建议使用


\documentclass{article}

\usepackage{tabularx}
\usepackage{xurl}


\begin{document}

\begin{tabularx}{\textwidth}{|c|X|X|c|}
\hline
S.no & \textbf{headline} & \textbf{article\_link} &  \textbf{is\_sarcastic} \\ \hline
1 &
  man who said 'yes' to life found with mountain bike at bottom of gorge &
  \url{https://local.theonion.com/man-who-said-yes-to-life-found-with-mountain-bike-at-bo-1819573183} &
  1\\
\hline 
2 &
  tina fey is worried about what the internet is doing to society &
  \url{https://www.huffingtonpost.com/entry/tina-fey-internet_us_5848252ce4b08c82e888ff80} &
  0 \\
\hline 
3 &
  why a woman refuses to leave her husband who threatened to kill her &
  \url{https://www.huffingtonpost.com/entry/pro-fighter-allegedly-abuses-wife_n_6072618.html} &
  0 \\ \hline
\end{tabularx}

\end{document}

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.