
我是新用戶。我在 lyX 方面遇到了麻煩,特別是如何\input{file.tex}
正確使用。錯誤:「未定義的控制序列」。實際上我不確定必須在哪裡指定路徑以便 LyX 可以識別並找到它。到目前為止,我使用了“插入”>“浮動”>“表格”(這裡是我要附加 2 個不同表格的地方)。在 LateX 序言(文件 > 設定 > LateX 序言)中,我使用以下內容:
% Packages for tables
\usepackage{booktabs}% Pretty tables
\usepackage{threeparttablex}% For Notes below table
% *****************************************************************
% siunitx
% *****************************************************************
\newcommand{\sym}[1]{\rlap{#1}}
\usepackage{siunitx}
\sisetup{
detect-mode,
group-digits = false,
input-symbols = ( ) [ ] - +,
table-align-text-post = false,
input-signs = ,
}
% Character substitution that prints brackets and the minus symbol in text mode. Thanks to David Carlisle
\def\yyy{%
\bgroup\uccode`\~\expandafter`\string-%
\uppercase{\egroup\edef~{\noexpand\text{\llap{\textendash}\relax}}}%
\mathcode\expandafter`\string-"8000 }
\def\xxxl#1{%
\bgroup\uccode`\~\expandafter`\string#1%
\uppercase{\egroup\edef~{\noexpand\text{\noexpand\llap{\string#1}}}}%
\mathcode\expandafter`\string#1"8000 }
\def\xxxr#1{%
\bgroup\uccode`\~\expandafter`\string#1%
\uppercase{\egroup\edef~{\noexpand\text{\noexpand\rlap{\string#1}}}}%
\mathcode\expandafter`\string#1"8000 }
\def\textsymbols{\xxxl[\xxxr]\xxxl(\xxxr)\yyy}
% *****************************************************************
% Estout related things
% *****************************************************************
\let\estinput=\input % define a new input command so that we can still flatten the document
\newcommand{\estwide}[3]{
\vspace{.75ex}{
\textsymbols% Note the added command here
\begin{tabular*}
{\textwidth}{@{\hskip\tabcolsep\extracolsep\fill}l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\addlinespace[.75ex]
\end{tabular*}
}
}
\newcommand{\estauto}[3]{
\vspace{.75ex}{
\textsymbols% Note the added command here
\begin{tabular}{l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\addlinespace[.75ex]
\end{tabular}
}
}
% Allow line breaks with \\ in specialcells
\newcommand{\specialcell}[2][c]{%
\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}
}
% *****************************************************************
% Custom subcaptions
% *****************************************************************
% Note/Source/Text after Tables
% The new approach using threeparttables to generate notes that are the exact width of the table.
\newcommand{\Figtext}[1]{%
\begin{tablenotes}[para,flushleft]
\hspace{6pt}
\hangindent=1.75em
#1
\end{tablenotes}
}
\newcommand{\Fignote}[1]{\Figtext{\emph{Note:~}~#1}}
\newcommand{\Figsource}[1]{\Figtext{\emph{Source:~}~#1}}
\newcommand{\Starnote}{\Figtext{* p < 0.1, ** p < 0.05, *** p < 0.01. Standard errors in parentheses.}}% Add significance note with \starnote
我感謝您的支持!謝謝你!
答案1
該命令\input{}
應該在沒有用戶前言以及您的前言的新 LyX 檔案中運行。在文件正文中嘗試以下操作:
Ctrl+L
(這會產生一個 ERT - 邪惡的紅色文字方塊)- 在 ERT 框內寫入
\input{/your/path/here/file}
(可以省略.tex
副檔名),或僅\input{file}
在子文件與主文件位於同一目錄中時寫入。
您可以使用選單獲得相同的結果Insert > File > Children document
(或類似的結果,我無法檢查確切的英文標籤)。結果是相同的,唯一的區別是,您將看到一個可點擊的灰色框,可以透過 Lyx 視窗進行更改,而不是被 LyX 忽略的 LaTeX 程式碼:
如果出現「未定義的控制序列」錯誤,則應該是由於子文件中的某些違規命令所致。請注意,file.tex
必須只是文件正文的一部分,而不是完整的 LaTeX 文件。首先檢查\input{}
一些純文字(“ Hello, Word!
”就足夠了)或像這樣的簡單表格是否可以正常工作:
\begin{tabular}{|l|l|l|}
\hline
11 & 12 & 13\\
21 & 22 & 23\\
31 & 32 & 33\\
\hline
\end{tabular}