嗨,我想在文档中增加一行。问题是它告诉我 \hline 是“未定义的控制序列”...
我尝试创建一个小示例文件,但问题是我使用了我们大学的大型模板,无法运行这个小文件。它会像这样:(由于我不知道哪些包对这个问题很重要,所以我只是复制了它们,很抱歉)
\documentclass[11pt,a4paper,english,oneside,final]{book} %To exclude pictures - "draft", to include pictures - "final" (LUCA)
\usepackage{etex} %Because of many packages --> Extended TeX.
\usepackage[left=1in, right=1in]{geometry} %Helps to structure the paper layout.
\usepackage[Lenny]{fncychap} %Design of the thesis.
\usepackage[utf8]{inputenc} %Due to vowels.
\usepackage[british]{babel} %Define the language style.
\usepackage{dsfont} %Nice style for the indicator function.
\usepackage{fancyhdr} %To customize the headers and footers.
\usepackage{booktabs} %In case you need \cmidrule or \addlinespace in tables.
\usepackage[hang,bottom,stable,multiple]{footmisc} %Style of footnotes.
\usepackage{appendix} %For the \appendixpage command.
%Load some mathematical packages.
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{etoolbox} %To remove the page number on \appendixpage.
\usepackage{amsthm} %For theorems, definitions etc.
\usepackage{thmtools} %For theorems, definitions etc.
\usepackage{setspace} %Use double spacing.
\usepackage{lipsum} %For the \lipsum command to generate a text.
\usepackage{datetime} %For the specification of the date.
%\usepackage{tocloft} %The ToC, LoF and LoT each appear not necessarily on a new page.
\usepackage{graphicx,listings,xcolor,textcomp} %For the graphics, listings etc.
\usepackage{mcode} %To implement a Matlab code.
\usepackage[margin=10pt, font=small, labelfont=bf, labelsep=endash]{caption} %Customize the captions.
\usepackage{chngcntr} %To use counterwithout.
\usepackage{epstopdf} %For inserting .eps files into the document.
\usepackage{pdfpages} %For inserting .pdf files as a whole page (LUCA)
\usepackage{hyperref} %Must be loaded at the end.
\usepackage{xparse} %Load for \NewDocumentCommand command.
\usepackage{cleveref} %For the command \cref, load after hyperref.
\usepackage{arydshln} %Due to the capability to draw horizontal/vertical dash-lines.
\usepackage{array,hhline} %To create tables and matrices.
\usepackage{rotating} %To rotate a table.
\usepackage{tabularx} %An extended version of tabular.
%-----------------
\usepackage{amssymb,amsmath} %Um Mathematische Formeln schreiben zu können
%\usepackage{apacite} %Um APA Style zu verwenden --> Funktioniert nicht. Man muss dann zuerst natbib rauskommentieren aber wohl auch noch viel in der .bib Datei anpassen...!
\usepackage[sort,round]{natbib} %For the bibliography.
%-----------------
%
%Setup of the reference links.
\hypersetup{
colorlinks=false,
linkcolor=blue,
citecolor=blue,
filecolor=magenta,
urlcolor=blue}
%Define some reasonable margins.
\setlength{\textwidth}{6.6in}
\setlength{\textheight}{8.8in}
\setlength{\topmargin}{-0.1in}
\setlength{\oddsidemargin}{0in}
\setlength{\parskip}{1mm}
\bibliographystyle{abbrvnat} %Reference style.
\allowdisplaybreaks[1] %Page breaks of equations are allowed, but avoided if possible. 2-4 more relaxed.
%New command for the UZH logo.
\newcommand*{\plogo}{\includegraphics{uzh_logo_e_pos}}
%New command for the differential d to have an ordinary d.
\makeatletter
\newcommand{\ud}{\mathrm{d}}
\makeatother
%Remove page number on \appendixpage. Use the package 'etoolbox'.
\makeatletter
\patchcmd{\@chap@pppage}{\thispagestyle{plain}}{\thispagestyle{empty}}{}{}
\makeatother
%Declare Definitions, Theorems etc.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\declaretheorem[style=definition,qed=$\blacktriangleleft$, numberwithin=chapter]{remark} %additional options; numberwithin=,..., see 'Thmtools' Users’ Guide
\declaretheorem[style=definition,qed=$\triangle$,numberwithin=chapter]{definition}
\newtheorem{ass}{Assumption}[chapter]
\newtheorem{prop}{Proposition}[chapter]
\newtheorem{lemma}{Lemma}[chapter]
\declaretheorem[style=definition,qed=$\perp$,numberwithin=chapter]{example}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{coroll}{Corollary}[chapter]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Readjust the numbering.
\counterwithout{footnote}{chapter}
\numberwithin{equation}{chapter}
\begin{document}
\begin{table}[htbp]
\centering
\caption{Add caption}
\begin{tabular}{rrr}
\toprule
Time & Returns & Value \\
\midrule
\multicolumn{1}{l}{0} & & \multicolumn{1}{l}{100} \\
\multicolumn{1}{l}{1} & 60\% & \multicolumn{1}{l}{160} \\
\multicolumn{1}{l}{2} & -30\% & \multicolumn{1}{l}{112} \\
\hline
\multicolumn{2}{l}{arithmetic mean return} & 15.00\% \\
\multicolumn{2}{l}{geometric mean return} & 5.83\% \\
\multicolumn{2}{l}{variance of the returns} & 20.25\% \\
\bottomrule
\end{tabular}%
\label{tab:addlabel}%
\end{table}%
\end{document}
当我删除“\hline”时,它在我的实际 tex 文件中运行正常。但是当我添加 \hline 时,我收到错误。
我认为 \usepackage{tabularx} 很重要。
有人能帮助我吗?
谢谢
答案1
您应该tabularx
在 之前加载arydshln
。
也加载hyperref
并cleveref
持续。