
我想排版一個表格,列出一些方程式,例如
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}