如何定義表格列總是數學方程,而其他列是文字?

如何定義表格列總是數學方程,而其他列是文字?

我想排版一個表格,列出一些方程式,例如

Euler's formula  &    e^{i\phi} &= \cos\phi + i\sin\phi
Euler's identity & 1 + e^{i\pi} &= 0

將其放入\begin{tabular}{l|rl}環境中,所有公式都需要用$' 括起來,而使用array文本時必須將其放入\text{...}.有什麼方法可以定義一個預設包含文本,而另一個預設包含數學模式?

答案1

\documentclass{article}
\usepackage{array}
\begin{document}

\begin{tabular}{@{} l >{$}r<{$} @{\kern1.4pt} >{$}l<{$} @{}}
Euler's formula  &    e^{i\phi} &= \cos\phi + i\sin\phi \\
Euler's identity & 1 + e^{i\pi} &= 0\\
\end{tabular}

\end{document}

在此輸入影像描述

預設表格標題的定義是

-----------col 1---------- ------------col 2 ---------- ---------- col 3---------
\tabcolsep TEXT \tabcolsep \tabcolsep $MATH$ \tabcolsep \tabcolsep $MATH$ \tabcolsep

@{...}可以替換預設長度\tabcolsep@{}忽略這個額外的水平空間。是嗎之間兩列然後替換兩個都 \tabcolsep

答案2

毛皮未來參考,tabu包裹讓這變得相當容易:

\documentclass[a4paper, 12 pt]{scrartcl}

\usepackage[utf8]{inputenx}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{amsmath}
\usepackage{tabu}

\begin{document}

\section{Another possibility}

\begin{tabu} to 0.75\textwidth{X[l] X[r, $] X[l, $]}
Euler's formula  &    e^{i\phi} &= \cos\phi + i\sin\phi \\
Euler's identity & 1 + e^{i\pi} &= 0
\end{tabu}

\end{document}

因此,只需在列的定義中添加 $,其整個內容就會以數學模式處理。這是螢幕上的樣子: 螢幕上的樣子

相關內容