我在尝试编译longtable
标题时出现此错误。没有标题,一切都正常。我还在\\
标题后面添加了。
!未定义的控制序列。
我尝试了所有相关方法,试图找出如何消除该错误,但还是无法解决。如果您知道该怎么做,我将不胜感激。
这是我的 LaTeX 代码:
% Preamble
%----------------------------------------------------------------------------------
\documentclass[11pt]{article}
% Default Package Setup
\usepackage{setspace,graphicx,epstopdf,amsmath,amsfonts,amssymb,amsthm}
\usepackage{marginnote,datetime,enumitem,subfigure,rotating,fancyvrb}
\usepackage{hyperref,float}
\usepackage[longnamesfirst]{natbib}
\usepackage{array}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{multirow}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\usepackage[autostyle]{csquotes}
\usepackage{caption}
\usepackage{natbib}
\captionsetup[table]{belowskip=10pt}
\usdate
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{setspace}
\usepackage{xltabular}
\usepackage{makecell}
\usepackage{pdflscape}
% These next lines allow including or excluding different versions of text
% using the package versionPO.sty
% Notes options
\usepackage[margin=1in,paperwidth=10in,right=2.5in]{geometry}%
\usepackage[textwidth=1.4in,shadow,colorinlistoftodos]{todonotes}%
\usepackage[margin=1in]{geometry}%
% Allow todonotes inside footnotes without blowing up LaTeX
% Next command works but now notes can overlap. Instead, we'll
% a special footnote note command that performs this redefinition.
%\renewcommand{\marginpar}{\marginnote}%
% Save original definition of \marginpar
\let\oldmarginpar\marginpar
% Workaround for todonotes problem with natbib (To Do list title comes out wrong)
\makeatletter\let\chapter\@undefined\makeatother % Undefine \chapter for todonotes
% Define note commands
\newcommand{\smalltodo}[2][] {\todo[caption={#2}, size=\scriptsize, fancyline, #1] {\begin{spacing}{.5}#2\end{spacing}}}
\newcommand{\rhs}[2][]{\smalltodo[color=green!30,#1]{{\bf RS:} #2}}
\newcommand{\rhsnolist}[2][]{\smalltodo[nolist,color=green!30,#1]{{\bf RS:} #2}}
\newcommand{\rhsfn}[2][]{% To be used in footnotes (and in floats)
\renewcommand{\marginpar}{\marginnote}%
\smalltodo[color=green!30,#1]{{\bf RS:} #2}%
\renewcommand{\marginpar}{\oldmarginpar}}
%\newcommand{\textnote}[1]{\ifnotes{{\noindent\color{red}#1}}{}}
\newcommand{\textnote}[1]{\ifnotes{{\colorbox{yellow}{{\color{red}#1}}}}{}}
% Command to start a new page, starting on odd-numbered page if two side option
% is selected above
\newcommand{\clearRHS}{\clearpage\thispagestyle{empty}\cleardoublepage\thispagestyle{plain}}
% Number paragraphs and subparagraphs and include them in TOC
\setcounter{tocdepth}{3}
% RFS-specific includes:
% Use endnotes instead of footnotes
\usepackage{endnotes}
% RFS-specific formatting of sections, etc.
\captionsetup{labelfont=bf,justification=raggedright,singlelinecheck=false}
\newcommand{\citeRFS}[1]{\citeauthor{#1}~\citeyear{#1}}
% Stick footnotes to the end of the page.
\usepackage[bottom]{footmisc}
% Define theorem-like commands and a few random function names.
\newtheorem{condition}{Condition}
\newtheorem{corollary}{Corollary}
\newtheorem{proposition}{Proposition}
\newtheorem{obs}{Observation}
\newcommand{\argmax}{\mathop{\rm arg\,max}}
\newcommand{\sign}{\mathop{\rm sign}}
\newcommand{\defeq}{\stackrel{\rm def}{=}}
% Abbreviations
% Load packages
\usepackage[nonumberlist, nopostdot]{glossaries}
\setacronymstyle{long-short}
\makenoidxglossaries
\renewcommand\glossaryname{List of Abbreviations and Acronyms}
% Definitions
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\newacronym{mla}{MLA}{Machine Learning Algorithm}
% Special command to define plural forms that not add an S to the singular form.
\newacronym[\glslongpluralkey={Real Estate Operating Companies}]{reoc}{REOC}{Real Estate Operating Company}
% Appendix
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
\appendix
\setcounter{secnumdepth}{0}
\section{Appendix}
\subsection*{A.1\quad Definition of Main Variables used in the Study}
\label{sec:App1}
\begingroup
\begin{scriptsize}
\begin{spacing}{1}
\begin{longtable}{llll}
\caption{Overview Variables}\\
\toprule
\textbf{\begin{tabular}[c]{@{}l@{}}Variable \\ Category\end{tabular}} & \textbf{Variable Name} & \textbf{Description} & \textbf{Formula} \\ \midrule
\textit{Assets} & Cash & \begin{tabular}[c]{@{}l@{}}The most liquid asset of the firm, used \\ to acquire goods and services\end{tabular} & \\
& ShortTermInvestments & \begin{tabular}[c]{@{}l@{}}Securities that are expected to be sold \\ within a year\end{tabular} & \\
& CashAndShortTermInvestments & \begin{tabular}[c]{@{}l@{}}The sum of cash and short-term \\ investments\end{tabular} & \\
& Receivables & Short-term claims against customers & \\
& Inventories & \begin{tabular}[c]{@{}l@{}}Assets intended to be sold in \\ the ordinary course of business\end{tabular} & \\
& PropertyPlantEquipment & \begin{tabular}[c]{@{}l@{}}Long-term tangible assets used in e.g. \\ production or administration\end{tabular} & \\
& PrepaidExpenses & \begin{tabular}[c]{@{}l@{}}Assets created through advanced \\ payments for goods or services to \\ be received in the future\end{tabular} & \\
& OtherCurrentAssets & \begin{tabular}[c]{@{}l@{}}Other current assets which do not \\ include the items listed above and \\ are converted within a year\end{tabular} & \\
& CurrentAssets & \begin{tabular}[c]{@{}l@{}}Total current assets that are \\ expected to be converted \\ to cash within a year\end{tabular} & \\
& IntangibleAssets & \begin{tabular}[c]{@{}l@{}}Assets that are not physical in nature \\ e.g. Goodwill\end{tabular} & \\
& OtherAssets & \begin{tabular}[c]{@{}l@{}}Other assets are a grouping of \\ accounts that have not been \\ listed above\end{tabular} & \\
& YoYTotalAssetGrowth & Yearly growth of total assets & \begin{tabular}[c]{@{}l@{}}(Total assets current year / \\ Total assets last year) - 1\end{tabular} \\ \midrule
\textit{Liabilities} & OtherCurrentLiabilities & \begin{tabular}[c]{@{}l@{}}Claims against the company held by \\ others than suppliers\end{tabular} & \\
& CurrentLiabilities & \begin{tabular}[c]{@{}l@{}}Sum of all obligations payable \\ within one year\end{tabular} & \\
& LongTermDebt & \begin{tabular}[c]{@{}l@{}}Long-term financial liability for \\ which payments will be required \\ after one year from initiation\end{tabular} & \\
& OtherLiabilities & \begin{tabular}[c]{@{}l@{}}Balance sheet entry used to group\\ together liabilities that are not \\ assigned to common liabilities\end{tabular} & \\
& RetainedEarnings & \begin{tabular}[c]{@{}l@{}}Retained earnings are the profits\\ earned to date, less dividends \\ paid to investors\end{tabular} & \\
& OrdinaryStock & \begin{tabular}[c]{@{}l@{}}Equity line item that is subordinate \\ to all other types of equity\end{tabular} & \\
& WorkingCapital & \begin{tabular}[c]{@{}l@{}}Inidactes the firms efficiency \\ as well as its short-term \\ financial stability\end{tabular} & \begin{tabular}[c]{@{}l@{}}Current assets - \\ Current liabilities\end{tabular} \\ \midrule
\textit{\begin{tabular}[c]{@{}l@{}}Income \\ Statement\end{tabular}} & Revenue & \begin{tabular}[c]{@{}l@{}}Income generated from normal \\ business operations\end{tabular} & \\
& YoYRevenueGrowth & Yearly growth of revenue & \begin{tabular}[c]{@{}l@{}}(Revenue current year / \\ Revenue last year) - 1\end{tabular} \\
& CostOfGoodsSold & \begin{tabular}[c]{@{}l@{}}Direct costs related to the \\ manufacturing of \\ the goods sold\end{tabular} & \\
& OperatingExpenses & \begin{tabular}[c]{@{}l@{}}Sum of the expenses a business incurs \\ through its normal operations\end{tabular} & \\
& OtherOperatingExpense & \begin{tabular}[c]{@{}l@{}}Overhead expenses which do not \\ depend on general operations such \\ as sales or production\end{tabular} & \\
& StaffExpense & \begin{tabular}[c]{@{}l@{}}Expense for employees such \\ as salaries\end{tabular} & \\
& ResearchAndDevelopment & \begin{tabular}[c]{@{}l@{}}Includes the cost associated to \\ activities that create or improve \\ products or processes\end{tabular} & \\
& DepreciationAndAmortization & \begin{tabular}[c]{@{}l@{}}Non-cash expense of both tangible \\ and intangible assets over time\end{tabular} & \\
& EBIT & Earnings Before Interests and Taxes & \\
& EBITMargin & \begin{tabular}[c]{@{}l@{}}Percentage of revenue that turned \\ into EBIT\end{tabular} & EBIT/Revenue \\
& InterestExpense & \begin{tabular}[c]{@{}l@{}}Non-operating expense which \\ represents interest payable\end{tabular} & \\
& PretaxIncome & \begin{tabular}[c]{@{}l@{}}Entire income of operations after \\ operating expense, interest and D\&A \\ but before taxes\end{tabular} & \\
& IncomeTaxes & Expense paid for taxes & \\
& NetIncomeorLoss & Profit or loss for the period & \\
& NonOperatingIncomeorExpense & \begin{tabular}[c]{@{}l@{}}Expense or income incurred which \\ does not relate to its main \\ business activities\end{tabular} & \\ \midrule
\textit{Cash Flow} & CashFlowInvesting & \begin{tabular}[c]{@{}l@{}}Amount of cash generated or used in \\ investing activities\end{tabular} & \\
& CashFlowOperating & \begin{tabular}[c]{@{}l@{}}Amount of cash generated or used in \\ ongoing regular business activities\end{tabular} & \\
& CashFlowFinancing & \begin{tabular}[c]{@{}l@{}}Amount of cash generated or used in \\ financing activities\end{tabular} & \\
& Dividends & \begin{tabular}[c]{@{}l@{}}Portion of earnings paid from \\ company to its shareholders\end{tabular} & \\ \midrule
\textit{Ratios} & CurrentRatio & \begin{tabular}[c]{@{}l@{}}Liquidity measure which shows a \\ company's ability to pay short-term \\ liabilities\end{tabular} & \\
& EPS & \begin{tabular}[c]{@{}l@{}}Portion of the firm's income which is \\ available to the common stockholders\end{tabular} & \begin{tabular}[c]{@{}l@{}}(Net income - \\ Preferred stock dividends) \\ / Common shares outstanding\end{tabular} \\
& EPSExcludingExtraordinaryItems & \begin{tabular}[c]{@{}l@{}}EPS but computed with adjusted \\ Income, not taking in account \\ one-time items\end{tabular} & \begin{tabular}[c]{@{}l@{}}(Adjusted net income - \\ Preferred stock dividends) / \\ Common shares outstanding\end{tabular} \\
& TotalAssetTurnover & \begin{tabular}[c]{@{}l@{}}Compares sales to assets to measure \\ the efficiency of the firm\end{tabular} & Net sales / Total assets \\
& InventoryTurnover & \begin{tabular}[c]{@{}l@{}}Shows number of times that a \\ business sells and replaces its \\ inventory within one year\end{tabular} & COGS / Ending Inventory \\
& PriceToBookRatio & \begin{tabular}[c]{@{}l@{}}Compares market price of the firm's\\ shares to its book value to measure \\ the market's valuation of the stock\end{tabular} & \begin{tabular}[c]{@{}l@{}}Share price / (Total assets - \\ Intangible assets - Liabilities)\end{tabular} \\
& PriceEarningsRatio & \begin{tabular}[c]{@{}l@{}}Shows the multiple of earnings that \\ investors are willing to pay to buy \\ the company's shares\end{tabular} & Share price / Earnings per share \\
& NetSalesWorkingCapitalRatio & \begin{tabular}[c]{@{}l@{}}Measures how efficiently a company \\ is applying its working capital \\ to achieve sales\end{tabular} & Net sales / Working capital \\
& ROE & \begin{tabular}[c]{@{}l@{}}Measure used by investors which \\ indicates the company's performance\end{tabular} & \begin{tabular}[c]{@{}l@{}}Net Income / \\ Shareholders' equity\end{tabular} \\
& ROA & \begin{tabular}[c]{@{}l@{}}Compares the firm's earnings to the\\ total assets and indicated the \\ efficiency of the usage of assets\end{tabular} & After tax profits / Total assets \\
& InterestCoverage & \begin{tabular}[c]{@{}l@{}}Measures a company's ability to pay \\ interest obligations on its \\ outstanding debt\end{tabular} & EBIT / Interest expense \\
& EBITCashRatio & \begin{tabular}[c]{@{}l@{}}Measures the relationship of \\ EBIT and cash\end{tabular} & EBIT / Cash \\
& FinancialLeverage & \begin{tabular}[c]{@{}l@{}}Measures the ratio of total \\ debt to equity\end{tabular} & Total debt / Total equity \\
& SolvencyRatio & \begin{tabular}[c]{@{}l@{}}Measures if the firm's cash flow is \\ sufficient to meet its short- \\ and long-term liabilities\end{tabular} & \begin{tabular}[c]{@{}l@{}}(Net income + depreciation) / \\ (Total liabilities)\end{tabular} \\
& QuickRatio & \begin{tabular}[c]{@{}l@{}}Measures the firm's ability to pay off \\ its short-term obligations with \\ liquid assets\end{tabular} & \begin{tabular}[c]{@{}l@{}}(Cash + Marketable securities + \\ Receivables) / Current liabilities\end{tabular} \\
& DividendYield & \begin{tabular}[c]{@{}l@{}}Used by investors to determine \\ their yield by comparingthe \\ dividend paid to the firm's \\ share price\end{tabular} & \begin{tabular}[c]{@{}l@{}}Yearly dividend paid / \\ Share price\end{tabular} \\
& DebtAssetsRatio & \begin{tabular}[c]{@{}l@{}}Measures the ratio of total debt \\ to total assets\end{tabular} & Total debt / Total assets \\
& CashAssetsRatio & \begin{tabular}[c]{@{}l@{}}Measures the ratio of cash to \\ total assets\end{tabular} & Cash / Total assets \\ \midrule
\textit{Macro} & TradeBalance & \begin{tabular}[c]{@{}l@{}}Measures the monetary difference \\ between exports and imports\end{tabular} & Exports - Imports \\
\textit{} & 10YearSwissGovernmentBondYield & \begin{tabular}[c]{@{}l@{}}The yield for the 10-year Swiss \\ goverment bond\end{tabular} & \\ \midrule
\textit{Other} & MarketCapitalization & \begin{tabular}[c]{@{}l@{}}The firm's current market value \\ (yearly measured)\end{tabular} & \begin{tabular}[c]{@{}l@{}}Number of shares outstanding * \\ Current share price\end{tabular} \\
& MarketBeta & \begin{tabular}[c]{@{}l@{}}Measures systematic risk of an \\ individual stock compared to \\ unsystematic risk of the market\end{tabular} & \begin{tabular}[c]{@{}l@{}}Covariance (Return stock, \\ Return market) / \\ Variance (Return market)\end{tabular} \\
& Employees & \begin{tabular}[c]{@{}l@{}}Number of employees gives an \\ indication of the firm's size\end{tabular} & \\
\bottomrule
\end{longtable}
\end{spacing}
\end{scriptsize}
\endgroup
\clearpage
\end{document}
在这里您可以看到我的第 2 列不是顶部对齐,而是中间对齐到描述:
答案1
关于更新后的问题:
您的问题中的代码可以进一步归结为以下 MWE:
\documentclass[11pt]{article}
\usepackage{caption}
\usepackage{xltabular}
\begin{document}
\begin{longtable}{l}
\caption{Overview Variables}\\
text in table
\end{longtable}
\end{document}
会产生以下错误信息:
! Undefined control sequence. \LT@c@ption ...ndcsname }{#3}\LT@captionlistentry{#2}l.10 \caption{Overview Variables}\\
cpation
可以通过改变和的加载顺序来消除错误消息,xltabular
并加载后者后 前者。通过这个小小的改变,MWE 就变得可编译了。
\documentclass[11pt]{article}
\usepackage{xltabular}
\usepackage{caption}
\begin{document}
\begin{longtable}{l}
\caption{Overview Variables}\\
text in table
\end{longtable}
\end{document}
这当然也可以应用于您的大型示例文档。由于我们已经看到某些包的加载顺序确实很重要,您可能希望借此机会清理您的序言。hyperref
通常(除了少数例外)应该是最后加载的包。另外,请避免加载包超过一次。您的序言至少加载natbib
两次booktabs
。
根据您目前提供的信息,错误消息无法重现。但是,这里有三种改进布局的表格变体。其中一种可能适合您的需求:
\documentclass{article}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{xltabular}
\usepackage{makecell}
\renewcommand{\theadfont}{\bfseries}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{pdflscape}
\begin{document}
{\small
\begin{xltabular}{\textwidth}{llLL}
\caption{Overview Variables}\\
\toprule
\thead{Variable \\ Category} & \thead{Variable Name} & \thead{Description} & \thead{Formula} \\ \midrule
\endfirsthead
\toprule
\thead{Variable \\ Category} & \thead{Variable Name} & \thead{Description} & \thead{Formula} \\ \midrule
\endhead
\textit{Assets} & Cash & The most liquid asset of the firm, used to acquire goods and services & \\
& ShortTermInvestments & Securities that are expected to be sold within a year & \\
& CashAndShortTermInvestments & The sum of cash and short-term investments & \\
& Receivables & Short-term claims against customers & \\
& Inventories & Assets intended to be sold in the ordinary course of business & \\
& PropertyPlantEquipment & Long-term tangible assets used in e.g. production or administration & \\
& PrepaidExpenses & Assets created through advanced payments for goods or services to be received in the future & \\
& OtherCurrentAssets & Other current assets which do not include the items listed above and are converted within a year & \\
& CurrentAssets & Total current assets that are expected to be converted to cash within a year & \\
& IntangibleAssets & Assets that are not physical in nature e.g. Goodwill & \\
& OtherAssets & Other assets are a grouping of accounts that have not been listed above & \\
& YoYTotalAssetGrowth & Yearly growth of total assets & (Total assets current year / Total assets last year) - 1 \\
\bottomrule
\end{xltabular}}
\newpage
{\small
\begin{xltabular}{\textwidth}{@{\quad\quad}lLL}
\caption{Overview Variables}\\
\toprule
Variable Name & Description & Formula \\ \midrule
\endfirsthead
\toprule
Variable Name & Description & Formula \\ \midrule
\endhead
\multicolumn{1}{l}{\textit{Assets}} \\
Cash & The most liquid asset of the firm, used to acquire goods and services & \\\addlinespace
\makecell[lt]{ShortTerm\\Investments} & Securities that are expected to be sold within a year & \\ \addlinespace
\makecell[lt]{CashAndShort\\TermInvestments} & The sum of cash and short-term investments & \\ \addlinespace
Receivables & Short-term claims against customers & \\\addlinespace
Inventories & Assets intended to be sold in the ordinary course of business & \\\addlinespace
\makecell[lt]{PropertyPlant\\Equipment} & Long-term tangible assets used in e.g. production or administration & \\\addlinespace
PrepaidExpenses & Assets created through advanced payments for goods or services to be received in the future & \\\addlinespace
\makecell[lt]{OtherCurrent\\Assets} & Other current assets which do not include the items listed above and are converted within a year & \\\addlinespace
CurrentAssets & Total current assets that are expected to be converted to cash within a year & \\\addlinespace
IntangibleAssets & Assets that are not physical in nature e.g. Goodwill & \\\addlinespace
OtherAssets & Other assets are a grouping of accounts that have not been listed above & \\\addlinespace
\makecell[lt]{YoYTotalAsset\\Growth} & Yearly growth of total assets & (Total assets current year / Total assets last year) - 1 \\
\bottomrule
\end{xltabular}}
\newpage
\begin{landscape}
\small
\begin{xltabular}{\linewidth}{@{\quad\quad}lLL}
\caption{Overview Variables}\\
\toprule
Variable Name & Description & Formula \\ \midrule
\endfirsthead
\toprule
Variable Name & Description & Formula \\ \midrule
\endhead
\multicolumn{1}{l}{\textit{Assets}} \\
Cash & The most liquid asset of the firm, used to acquire goods and services & \\\addlinespace
\makecell[lt]{ShortTerm\\Investments} & Securities that are expected to be sold within a year & \\ \addlinespace
\makecell[lt]{CashAndShort\\TermInvestments} & The sum of cash and short-term investments & \\ \addlinespace
Receivables & Short-term claims against customers & \\\addlinespace
Inventories & Assets intended to be sold in the ordinary course of business & \\\addlinespace
\makecell[lt]{PropertyPlant\\Equipment} & Long-term tangible assets used in e.g. production or administration & \\\addlinespace
PrepaidExpenses & Assets created through advanced payments for goods or services to be received in the future & \\\addlinespace
\makecell[lt]{OtherCurrent\\Assets} & Other current assets which do not include the items listed above and are converted within a year & \\\addlinespace
CurrentAssets & Total current assets that are expected to be converted to cash within a year & \\\addlinespace
IntangibleAssets & Assets that are not physical in nature e.g. Goodwill & \\\addlinespace
OtherAssets & Other assets are a grouping of accounts that have not been listed above & \\\addlinespace
\makecell[lt]{YoYTotalAsset\\Growth} & Yearly growth of total assets & (Total assets current year / Total assets last year) - 1 \\
\bottomrule
\end{xltabular}
\end{landscape}
\end{document}