
我是 LaTeX 新手,我正在用它來編寫如下問卷:
我目前的程式碼如下:
\begin{enumerate}
\item
Statement one.
\begin{tabular}{c c c c c c c}
\square & \square & \square & \square
& \square & \square & \square \\
Strongly agree & Moderately agree & Slightly agree &
Neither agree or disagree & Slightly disagree & Moderately disagree & Strongly disagree
\end{tabular}
\end{enumerate}
我收到這個錯誤:
請告訴我我的程式碼有什麼問題嗎?
答案1
\square
是一個數學模式構造,需要數學分隔符,如$\square$
.由於 的每個欄位tabular
在邏輯上與其他欄位分開,因此必須為包含 的每個儲存格新增數學模式\square
。我還添加了一個空行,以在其自己的行上形成答案選項。
對於圓圈,只需替換\square
為\bigcirc
。
如果全部a 的單元格tabular
處於數學模式,人們最好使用array
來代替tabular
,這本質上是 的數學模式版本tabular
。
\documentclass{article}
\usepackage[landscape,margin=1cm,]{geometry}
\usepackage{amssymb}
\begin{document}
\begin{enumerate}
\item
Statement one.
\begin{tabular}{c c c c c c c}
$\bigcirc$ & $\bigcirc$ & $\bigcirc$ & $\bigcirc$
& $\bigcirc$ & $\bigcirc$ & $\bigcirc$ \\
Strongly agree & Moderately agree & Slightly agree &
Neither agree or disagree & Slightly disagree & Moderately disagree & Strongly disagree
\end{tabular}
\end{enumerate}
\end{document}
答案2
如果您想避免重複輸入的乏味$...$
,您可以使用\Square
以下\Circle
命令wasysym
:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{wasysym}
\usepackage{array}
\begin{document}
\begin{enumerate}
\item Statement one.
\begin{tabular}[t]{c c c}
\Square & \Square & \Square \\
Strongly agree & Moderately agree & Slightly agree \\[2ex]
\bfseries\Circle \\
Neither agree or disagree \\[2ex]
\Square & \Square & \Square \\
Slightly disagree & Moderately disagree & Strongly disagree
\end{tabular}
\end{enumerate}
\end{document}