
進捗状況を追跡するために、文字とその下の数字を記した表を作成しています。
\documentclass{article}
\usepackage{xcolor, placeins, cmbright}
\usepackage[margin=0.5in]{geometry}
\begin{document}
\small
\begin{tabular}{|c|c|c|} \hline
S & \texttt{\textcolor{gray}{E}\textcolor{teal}{T}\textcolor{teal}{M}\textcolor{teal}{W}\textcolor{green}{D}\textcolor{gray}{T}\textcolor{green}{K}\textcolor{teal}{K}\textcolor{teal}{E}\textcolor{green}{V}\textcolor{gray}{K}\textcolor{teal}{A}\textcolor{teal}{A}\textcolor{teal}{A}\textcolor{teal}{T}\textcolor{gray}{A}\textcolor{teal}{A}\textcolor{teal}{M}\textcolor{teal}{T}\textcolor{teal}{K}\textcolor{gray}{A}\textcolor{teal}{T}\textcolor{teal}{E}\textcolor{teal}{T}\textcolor{teal}{V}\textcolor{gray}{D}\textcolor{green}{N}\textcolor{teal}{K}\textcolor{green}{D}\textcolor{teal}{I}\textcolor{gray}{E}\textcolor{teal}{R}\textcolor{teal}{F}\textcolor{teal}{I}\textcolor{green}{P}\textcolor{gray}{S}\textcolor{teal}{L}\textcolor{teal}{I}\textcolor{teal}{Q}\textcolor{teal}{C}\textcolor{gray}{I}\textcolor{teal}{A}\textcolor{teal}{D}\textcolor{green}{P}\textcolor{teal}{T}E-\textcolor{gray}{-}\textcolor{teal}{V}\textcolor{teal}{P}\textcolor{teal}{E}\textcolor{teal}{T}\textcolor{gray}{V}\textcolor{teal}{H}\textcolor{teal}{L}\textcolor{green}{L}\textcolor{teal}{G}\textcolor{gray}{A}\textcolor{green}{T}\textcolor{green}{T}\textcolor{green}{F}\textcolor{green}{V}\textcolor{gray}{A}\textcolor{teal}{E}\textcolor{green}{V}\textcolor{teal}{T}\textcolor{teal}{P}\textcolor{gray}{A}\textcolor{teal}{T}\textcolor{green}{L}\textcolor{teal}{S}\textcolor{teal}{I}\textcolor{gray}{M}\textcolor{teal}{V}\textcolor{green}{P}\textcolor{teal}{L}\textcolor{green}{L}\textcolor{gray}{S}\textcolor{teal}{R}\textcolor{teal}{G}\textcolor{green}{L}\textcolor{teal}{N}\textcolor{gray}{E}\textcolor{teal}{R}E\textcolor{teal}{-}T-\textcolor{teal}{-}\textcolor{teal}{G}\textcolor{gray}{I}\textcolor{teal}{K}\textcolor{green}{R}\textcolor{teal}{K}\textcolor{teal}{S}\textcolor{gray}{A}\textcolor{teal}{V}\textcolor{teal}{I}\textcolor{teal}{I}\textcolor{teal}{D}} & 270
\\
S track & \texttt{176 -181 -186 -191 -196 -201 -206 -211 -216 ---221 -226 -231 -236 -241 -246 -251 -256 --259 -264 -269} & 270
\\
\hline\end{tabular}
\end{document}
次のような結果が生成されます。
しかし、ご覧のとおり、両方の列のテキストは揃っていません。
明確に言うと、 は上記の1
真下にあるはずですE
。しかし、少し左にずれています。269
も間違った場所に表示されています。
問題は、等幅フォントであっても、スペースが異なって扱われていることである。\texttt
私はさまざまな場所から解決策を試してきました。表内の複数の行を揃える(唯一の場所ではありません) ですが、数字を揃える方法がわかりません。
大きな表の 100 列幅のセルに文字と数字を配置しようとしましたが、文字間のスペースが大きすぎて、表が読みにくくなりました。
私も試してみましたflushleft
が失敗しました。
1
LaTeX にを の真下に置くように指示する方法はありますかE
?
中央の列で使用するとうまくいきましたl
が、中央の列の右側では機能しないようです。
完成品の見た目が良ければ、全面的な再設計も検討します。
答え1
2 行の要素の数が同じではないことが、位置ずれの主な原因です。1 行目には 100 文字、2 行目には 101 文字あります (スペースを含めると)。以下は、そのままのビジュアルです。
ETMWDTKKEVKAAATAAMTKATETVDNKDIERFIPSLIQCIADPTE--VPETVHLLGATTFVAEVTPATLSIMVPLLSRGLNERE-T--GIKRKSAVIID
176 -181 -186 -191 -196 -201 -206 -211 -216 ---221 -226 -231 -236 -241 -246 -251 -256 --259 -264 -269
コードをもっと読みやすく書き直すのがベストです。そうすれば、間違いをより適切に特定できるようになります。私は内容に詳しくないので、数字に合わせて幅を分割しました。
\documentclass{article}
\usepackage{xcolor, cmbright}
\usepackage[margin=0.5in]{geometry}
\begin{document}
\small
\begin{tabular}{ | c | l | c | }
\hline
S & \ttfamily
\textcolor{gray}{E}\textcolor{teal}{T}\textcolor{teal}{M}%
\textcolor{teal}{W}\textcolor{green}{D}\textcolor{gray}{T}\textcolor{green}{K}%
\textcolor{teal}{K}\textcolor{teal}{E}\textcolor{green}{V}\textcolor{gray}{K}%
\textcolor{teal}{A}\textcolor{teal}{A}\textcolor{teal}{A}\textcolor{teal}{T}%
\textcolor{gray}{A}\textcolor{teal}{A}\textcolor{teal}{M}\textcolor{teal}{T}%
\textcolor{teal}{K}\textcolor{gray}{A}\textcolor{teal}{T}\textcolor{teal}{E}%
\textcolor{teal}{T}\textcolor{teal}{V}\textcolor{gray}{D}\textcolor{green}{N}%
\textcolor{teal}{K}\textcolor{green}{D}\textcolor{teal}{I}\textcolor{gray}{E}%
\textcolor{teal}{R}\textcolor{teal}{F}\textcolor{teal}{I}\textcolor{green}{P}%
\textcolor{gray}{S}\textcolor{teal}{L}\textcolor{teal}{I}\textcolor{teal}{Q}%
\textcolor{teal}{C}\textcolor{gray}{I}\textcolor{teal}{A}\textcolor{teal}{D}%
\textcolor{green}{P}\textcolor{teal}{T}E-%
\textcolor{gray}{-}\textcolor{teal}{V}\textcolor{teal}{P}\textcolor{teal}{E}%
\textcolor{teal}{T}\textcolor{gray}{V}\textcolor{teal}{H}\textcolor{teal}{L}%
\textcolor{green}{L}\textcolor{teal}{G}\textcolor{gray}{A}\textcolor{green}{T}%
\textcolor{green}{T}\textcolor{green}{F}\textcolor{green}{V}\textcolor{gray}{A}%
\textcolor{teal}{E}\textcolor{green}{V}\textcolor{teal}{T}\textcolor{teal}{P}%
\textcolor{gray}{A}\textcolor{teal}{T}\textcolor{green}{L}\textcolor{teal}{S}%
\textcolor{teal}{I}\textcolor{gray}{M}\textcolor{teal}{V}\textcolor{green}{P}%
\textcolor{teal}{L}\textcolor{green}{L}\textcolor{gray}{S}\textcolor{teal}{R}%
\textcolor{teal}{G}\textcolor{green}{L}\textcolor{teal}{N}\textcolor{gray}{E}%
\textcolor{teal}{R}E\textcolor{teal}{-}T%
-\textcolor{teal}{-}\textcolor{teal}{G}\textcolor{gray}{I}\textcolor{teal}{K}%
\textcolor{green}{R}\textcolor{teal}{K}\textcolor{teal}{S}\textcolor{gray}{A}%
\textcolor{teal}{V}\textcolor{teal}{I}\textcolor{teal}{I}\textcolor{teal}{D} & 270 \\
S track & \ttfamily
176~%
-181~%
-186~%
-191~%
-196~%
-201~%
-206~%
-211~%
-216~%
---221~%
-226~%
-231~%
-236~%
-241~%
-246~%
-251~%
-256~%
--259~%
-264~%
-269 & 270 \\
\hline
\end{tabular}
\end{document}