将表格单元格中的文本与换行符对齐

将表格单元格中的文本与换行符对齐

我需要在表格单元格中包含两行诗句,并需要强制对齐两行,使它们从同一点开始(这是水平对齐吗?)在下面的 MWE 中,需要修复的多行文本单元格位于第二行。修复此问题的最佳方法是什么?

\documentclass{article}

\begin{document}
\begin{tabular}{|l|c|l|}
\hline
\textit{\textbf{sūktisaṃkhyā}} & \textit{\textbf{sūktiḥ}} & \textit{\textbf{ślokasaṃkhyā}}\\
\hline
1. & anavadyatṛṇādino mṛgānmṛgayāghāya na bhūbhṛtāṃ ghnatām & 10\\
\hline
2. & \begin{tabular}{@{}c@{}}acirādupakarturācaredathavātmaupayikīmupakriyām |\\pṛthuritthamathāṇurastu sā na viśeṣe viduṣāmiha grahaḥ||\\\end{tabular}& 14\\
\hline
3. & vyavadhāvapi vā vidhoḥ kalāṃ mṛḍacūḍānilayāṃ na veda kaḥ & 19\\
\hline
4. & bruvate hi phalena sādhavo na tu kaṇṭhena nijopayogitām & 48 \\
\hline
5. & dhanināmitaraḥ satāṃ punarguṇavatsannidhireva sannidhiḥ & 53 \\
\hline
6. & svata eva satāṃ parārthatā grahaṇānāṃ hi yathā yathārthatā & 61 \\
\hline

\end{tabular}
\end{document}

平均能量损失

答案1

最简单的解决方案是使用\Centerstackstackengine我必须加载几何图形并修改 的值\tabcolsep以删除overfull \hbox消息:您的表格对于默认边距来说太宽。我还借此机会使用包为cellspace单元格添加了一些垂直填充。

\documentclass{article}
\usepackage{geometry} 
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{3pt}
\setlength{\cellspacebottomlimit}{3pt}
\usepackage[usestackEOL]{stackengine}

\begin{document}

\centering\setlength{\tabcolsep}{3pt}
\begin{tabular}{|l|Sc|l|}
\hline
\textit{\textbf{sūktisaṃkhyā}} & \textit{\textbf{sūktiḥ}} & \textit{\textbf{ślokasaṃkhyā}}\\
\hline
1. & anavadyatṛṇādino mṛgānmṛgayāghāya na bhūbhṛtāṃ ghnatām & 10\\
\hline
2. & \Centerstack[l]{acirādupakarturācaredathavātmaupayikīmupakriyām |\\pṛthuritthamathāṇurastu sā na viśeṣe viduṣāmiha grahaḥ||}& 14\\
\hline
3. & vyavadhāvapi vā vidhoḥ kalāṃ mṛḍacūḍānilayāṃ na veda kaḥ & 19\\
\hline
4. & bruvate hi phalena sādhavo na tu kaṇṭhena nijopayogitām & 48 \\
\hline
5. & dhanināmitaraḥ satāṃ punarguṇavatsannidhireva sannidhiḥ & 53 \\
\hline
6. & svata eva satāṃ parārthatā grahaṇānāṃ hi yathā yathārthatā & 61 \\
\hline

\end{tabular}

\end{document} 

在此处输入图片描述

相关内容