我有一个文件,经过一番努力,现在可以在 lyx 中使用了。但是,如果我将其导出到 tex 并从 texstudio 运行,我会得到之前在 Lyx 中遇到的原始错位 \noalign 错误。这是导出的 tex 代码:
% Preview source code
%% LyX 2.3.6.2 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{float}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
%% TABLES %%
% Packages for tables
\usepackage{booktabs}% Pretty tables
\usepackage{tabularx}
% *****************************************************************
% siunitx
% *****************************************************************
\newcommand{\sym}[1]{\rlap{#1}} % Thanks to Joseph Wright & David Carlisle
\usepackage{siunitx}
\sisetup{
detect-mode,
group-digits = false,
input-symbols = ( ) [ ] - +,
table-align-text-post = false,
input-signs = ,
}
% *****************************************************************
% Estout related things
% *****************************************************************
\ExplSyntaxOn
\cs_new:Npn \expandableinput #1
{ \use:c { @@input } { \file_full_name:n {#1} } }
\AddToHook{env/tabular/begin}
{ \cs_set_eq:NN \estinput \expandableinput }
\ExplSyntaxOff
\let\estinput=\input % define a new input command so that we can still flatten the document
\newcommand{\estauto}[3]{
\small{
\vspace{-1ex}{
\begin{tabular}{l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\addlinespace[.75ex]
\end{tabular}
}
}
}
\makeatother
\usepackage{babel}
\begin{document}
\begin{table}[H]
\caption{MWE Table \label{MWE}}
\centering
\small{
\estauto{/tables/MWE2.tex}{3}{c}
}
\end{table}
\end{document}
这是 MWE2.tex:
11 & 12 & 13 \\
21 & 22 & 23 \\
31 & 32 & 33 \\
答案1
感谢@Dan,表格前的反斜杠导致了这个问题。应该是:
\estauto{tables/MWE2.tex}{3}{c}
不是:
\estauto{/tables/MWE2.tex}{3}{c}