我使用的是 LYX 2.3.2 版。我有一个电子表格,它有 13 列,一列是名称,另一列是每月值。我使用常规的“插入”->“文件”->“外部材料”将电子表格导入浮点数。当我将 lyx 转换为 PDF 时,结果如下所示,列从页面上掉下来:
我尝试过的一些示例:格式化我导入的电子表格,例如更改标题和缩小列;将电子表格文件的比例设置为 1% 等等。
我将不胜感激任何帮助!
为了回应评论,下面是与所讨论的表格相对应的代码。
\begin{table}[H]
\begin{centering}
\def\inputGnumericTable{}\input{/home/abed/Google Drive/Utrecht Energy Science MSc/MSc Materials/Research Project/AnalysisData/torques_average_waves.tex}
\par\end{centering}
\caption{Torque imparted by ``average'' waves for a given month, in units
of $10^{5}Nm$}
\end{table}
为了回答另一个问题,该文件的内容如下:
自动生成的 .tex 文件如下所示:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%
%% This is the header of a LaTeX2e file exported from Gnumeric. %%
%% %%
%% This file can be compiled as it stands or included in another %%
%% LaTeX document. The table is based on the longtable package so %%
%% the longtable options (headers, footers...) can be set in the %%
%% preamble section below (see PRAMBLE). %%
%% %%
%% To include the file in another, the following two lines must be %%
%% in the including file: %%
%% \def\inputGnumericTable{} %%
%% at the beginning of the file and: %%
%% \input{name-of-this-file.tex} %%
%% where the table is to be placed. Note also that the including %%
%% file must use the following packages for the table to be %%
%% rendered correctly: %%
%% \usepackage[latin1]{inputenc} %%
%% \usepackage{color} %%
%% \usepackage{array} %%
%% \usepackage{longtable} %%
%% \usepackage{calc} %%
%% \usepackage{multirow} %%
%% \usepackage{hhline} %%
%% \usepackage{ifthen} %%
%% optionally (for landscape tables embedded in another document): %%
%% \usepackage{lscape} %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This section checks if we are begin input into another file or %%
%% the file will be compiled alone. First use a macro taken from %%
%% the TeXbook ex 7.7 (suggestion of Han-Wen Nienhuys). %%
\def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax}
%% Check for the \def token for inputed files. If it is not %%
%% defined, the file will be processed as a standalone and the %%
%% preamble will be used. %%
\ifundefined{inputGnumericTable}
%% We must be able to close or not the document at the end. %%
\def\gnumericTableEnd{\end{document}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%
%% This is the PREAMBLE. Change these values to get the right %%
%% paper size and other niceties. %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[12pt%
%,landscape%
]{report}
\usepackage[latin1]{inputenc}
\usepackage{fullpage}
\usepackage{color}
\usepackage{array}
\usepackage{longtable}
\usepackage{calc}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{ifthen}
\begin{document}
%% End of the preamble for the standalone. The next section is for %%
%% documents which are included into other LaTeX2e files. %%
\else
%% We are not a stand alone document. For a regular table, we will %%
%% have no preamble and only define the closing to mean nothing. %%
\def\gnumericTableEnd{}
%% If we want landscape mode in an embedded document, comment out %%
%% the line above and uncomment the two below. The table will %%
%% begin on a new page and run in landscape mode. %%
% \def\gnumericTableEnd{\end{landscape}}
% \begin{landscape}
%% End of the else clause for this file being \input. %%
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%
%% The rest is the gnumeric table, except for the closing %%
%% statement. Changes below will alter the table's appearance. %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\providecommand{\gnumericmathit}[1]{#1}
%% Uncomment the next line if you would like your numbers to be in %%
%% italics if they are italizised in the gnumeric table. %%
%\renewcommand{\gnumericmathit}[1]{\mathit{#1}}
\providecommand{\gnumericPB}[1]%
{\let\gnumericTemp=\\#1\let\\=\gnumericTemp\hspace{0pt}}
\ifundefined{gnumericTableWidthDefined}
\newlength{\gnumericTableWidth}
\newlength{\gnumericTableWidthComplete}
\newlength{\gnumericMultiRowLength}
\global\def\gnumericTableWidthDefined{}
\fi
%% The following setting protects this code from babel shorthands. %%
\ifthenelse{\isundefined{\languageshorthands}}{}{\languageshorthands{english}}
%% The default table format retains the relative column widths of %%
%% gnumeric. They can easily be changed to c, r or l. In that case %%
%% you may want to comment out the next line and uncomment the one %%
%% thereafter %%
\providecommand\gnumbox{\makebox[0pt]}
%%\providecommand\gnumbox[1][]{\makebox}
%% to adjust positions in multirow situations %%
\setlength{\bigstrutjot}{\jot}
\setlength{\extrarowheight}{\doublerulesep}
%% The \setlongtables command keeps column widths the same across %%
%% pages. Simply comment out next line for varying column widths. %%
\setlongtables
\setlength\gnumericTableWidth{%
37pt+%
42pt+%
34pt+%
34pt+%
32pt+%
37pt+%
33pt+%
35pt+%
32pt+%
31pt+%
30pt+%
30pt+%
30pt+%
0pt}
\def\gumericNumCols{13}
\setlength\gnumericTableWidthComplete{\gnumericTableWidth+%
\tabcolsep*\gumericNumCols*2+\arrayrulewidth*\gumericNumCols}
\ifthenelse{\lengthtest{\gnumericTableWidthComplete > \linewidth}}%
{\def\gnumericScale{\ratio{\linewidth-%
\tabcolsep*\gumericNumCols*2-%
\arrayrulewidth*\gumericNumCols}%
{\gnumericTableWidth}}}%
{\def\gnumericScale{1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%
%% The following are the widths of the various columns. We are %%
%% defining them here because then they are easier to change. %%
%% Depending on the cell formats we may use them more than once. %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifthenelse{\isundefined{\gnumericColA}}{\newlength{\gnumericColA}}{}\settowidth{\gnumericColA}{\begin{tabular}{@{}p{37pt*\gnumericScale}@{}}x\end{tabular}}
\ifthenelse{\isundefined{\gnumericColB}}{\newlength{\gnumericColB}}{}\settowidth{\gnumericColB}{\begin{tabular}{@{}p{42pt*\gnumericScale}@{}}x\end{tabular}}
\ifthenelse{\isundefined{\gnumericColC}}{\newlength{\gnumericColC}}{}\settowidth{\gnumericColC}{\begin{tabular}{@{}p{34pt*\gnumericScale}@{}}x\end{tabular}}
\ifthenelse{\isundefined{\gnumericColD}}{\newlength{\gnumericColD}}{}\settowidth{\gnumericColD}{\begin{tabular}{@{}p{34pt*\gnumericScale}@{}}x\end{tabular}}
\ifthenelse{\isundefined{\gnumericColE}}{\newlength{\gnumericColE}}{}\settowidth{\gnumericColE}{\begin{tabular}{@{}p{32pt*\gnumericScale}@{}}x\end{tabular}}
\ifthenelse{\isundefined{\gnumericColF}}{\newlength{\gnumericColF}}{}\settowidth{\gnumericColF}{\begin{tabular}{@{}p{37pt*\gnumericScale}@{}}x\end{tabular}}
\ifthenelse{\isundefined{\gnumericColG}}{\newlength{\gnumericColG}}{}\settowidth{\gnumericColG}{\begin{tabular}{@{}p{33pt*\gnumericScale}@{}}x\end{tabular}}
\ifthenelse{\isundefined{\gnumericColH}}{\newlength{\gnumericColH}}{}\settowidth{\gnumericColH}{\begin{tabular}{@{}p{35pt*\gnumericScale}@{}}x\end{tabular}}
\ifthenelse{\isundefined{\gnumericColI}}{\newlength{\gnumericColI}}{}\settowidth{\gnumericColI}{\begin{tabular}{@{}p{32pt*\gnumericScale}@{}}x\end{tabular}}
\ifthenelse{\isundefined{\gnumericColJ}}{\newlength{\gnumericColJ}}{}\settowidth{\gnumericColJ}{\begin{tabular}{@{}p{31pt*\gnumericScale}@{}}x\end{tabular}}
\ifthenelse{\isundefined{\gnumericColK}}{\newlength{\gnumericColK}}{}\settowidth{\gnumericColK}{\begin{tabular}{@{}p{30pt*\gnumericScale}@{}}x\end{tabular}}
\ifthenelse{\isundefined{\gnumericColL}}{\newlength{\gnumericColL}}{}\settowidth{\gnumericColL}{\begin{tabular}{@{}p{30pt*\gnumericScale}@{}}x\end{tabular}}
\ifthenelse{\isundefined{\gnumericColM}}{\newlength{\gnumericColM}}{}\settowidth{\gnumericColM}{\begin{tabular}{@{}p{30pt*\gnumericScale}@{}}x\end{tabular}}
\begin{longtable}[c]{%
b{\gnumericColA}%
b{\gnumericColB}%
b{\gnumericColC}%
b{\gnumericColD}%
b{\gnumericColE}%
b{\gnumericColF}%
b{\gnumericColG}%
b{\gnumericColH}%
b{\gnumericColI}%
b{\gnumericColJ}%
b{\gnumericColK}%
b{\gnumericColL}%
b{\gnumericColM}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% The longtable options. (Caption, headers... see Goosens, p.124) %%
% \caption{The Table Caption.} \\ %
% \hline % Across the top of the table.
%% The rest of these options are table rows which are placed on %%
%% the first, last or every page. Use \multicolumn if you want. %%
%% Header for the first page. %%
% \multicolumn{13}{c}{The First Header} \\ \hline
% \multicolumn{1}{c}{colTag} %Column 1
% &\multicolumn{1}{c}{colTag} %Column 2
% &\multicolumn{1}{c}{colTag} %Column 3
% &\multicolumn{1}{c}{colTag} %Column 4
% &\multicolumn{1}{c}{colTag} %Column 5
% &\multicolumn{1}{c}{colTag} %Column 6
% &\multicolumn{1}{c}{colTag} %Column 7
% &\multicolumn{1}{c}{colTag} %Column 8
% &\multicolumn{1}{c}{colTag} %Column 9
% &\multicolumn{1}{c}{colTag} %Column 10
% &\multicolumn{1}{c}{colTag} %Column 11
% &\multicolumn{1}{c}{colTag} %Column 12
% &\multicolumn{1}{c}{colTag} \\ \hline %Last column
% \endfirsthead
%% The running header definition. %%
% \hline
% \multicolumn{13}{l}{\ldots\small\slshape continued} \\ \hline
% \multicolumn{1}{c}{colTag} %Column 1
% &\multicolumn{1}{c}{colTag} %Column 2
% &\multicolumn{1}{c}{colTag} %Column 3
% &\multicolumn{1}{c}{colTag} %Column 4
% &\multicolumn{1}{c}{colTag} %Column 5
% &\multicolumn{1}{c}{colTag} %Column 6
% &\multicolumn{1}{c}{colTag} %Column 7
% &\multicolumn{1}{c}{colTag} %Column 8
% &\multicolumn{1}{c}{colTag} %Column 9
% &\multicolumn{1}{c}{colTag} %Column 10
% &\multicolumn{1}{c}{colTag} %Column 11
% &\multicolumn{1}{c}{colTag} %Column 12
% &\multicolumn{1}{c}{colTag} \\ \hline %Last column
% \endhead
%% The running footer definition. %%
% \hline
% \multicolumn{13}{r}{\small\slshape continued\ldots} \\
% \endfoot
%% The ending footer definition. %%
% \multicolumn{13}{c}{That's all folks} \\ \hline
% \endlastfoot
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\gnumericPB{\raggedright}\gnumbox[l]{\textbf{Name}}
&\gnumericPB{\raggedright}\gnumbox[l]{\textbf{Jan}}
&\gnumericPB{\raggedright}\gnumbox[l]{\textbf{Feb}}
&\gnumericPB{\raggedright}\gnumbox[l]{\textbf{Mar}}
&\gnumericPB{\raggedright}\gnumbox[l]{\textbf{Apr}}
&\gnumericPB{\raggedright}\gnumbox[l]{\textbf{May}}
&\gnumericPB{\raggedright}\gnumbox[l]{\textbf{Jun}}
&\gnumericPB{\raggedright}\gnumbox[l]{\textbf{Jul}}
&\gnumericPB{\raggedright}\gnumbox[l]{\textbf{Aug}}
&\gnumericPB{\raggedright}\gnumbox[l]{\textbf{Sep}}
&\gnumericPB{\raggedright}\gnumbox[l]{\textbf{Oct}}
&\gnumericPB{\raggedright}\gnumbox[l]{\textbf{Nov}}
&\gnumericPB{\raggedright}\gnumbox[l]{\textbf{Dec }}
\\
\gnumericPB{\raggedright}\gnumbox[l]{Port Shepstone}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.66283}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.523}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.535}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.82}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.5479}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.535}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.738}
&\gnumericPB{\raggedleft}\gnumbox[r]{1.427}
&\gnumericPB{\raggedleft}\gnumbox[r]{1.534}
&\gnumericPB{\raggedleft}\gnumbox[r]{1.633}
&\gnumericPB{\raggedleft}\gnumbox[r]{1.231}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.71}
\\
\gnumericPB{\raggedright}\gnumbox[l]{Puerto Colombia}
&\gnumericPB{\raggedleft}\gnumbox[r]{3.14227}
&\gnumericPB{\raggedleft}\gnumbox[r]{3.622}
&\gnumericPB{\raggedleft}\gnumbox[r]{2.734}
&\gnumericPB{\raggedleft}\gnumbox[r]{1.219}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.1477}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.143}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.354}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.086}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.001}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.001}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.153}
&\gnumericPB{\raggedleft}\gnumbox[r]{1.51}
\\
\gnumericPB{\raggedright}\gnumbox[l]{Port of Rotterdam}
&\gnumericPB{\raggedleft}\gnumbox[r]{1.81305}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.975}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.354}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.089}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.0613}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.032}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.027}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.045}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.195}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.77}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.995}
&\gnumericPB{\raggedleft}\gnumbox[r]{1.45}
\\
\gnumericPB{\raggedright}\gnumbox[l]{South Golden Beach}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.25007}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.24}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.283}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.22}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.2363}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.279}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.345}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.279}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.303}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.387}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.328}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.311}
\\
\gnumericPB{\raggedright}\gnumbox[l]{Katsuura}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.94642}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.882}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.803}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.427}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.184}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.052}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.043}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.012}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.134}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.311}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.363}
&\gnumericPB{\raggedleft}\gnumbox[r]{0.68}
\\
\end{longtable}
\ifthenelse{\isundefined{\languageshorthands}}{}{\languageshorthands{\languagename}}
\gnumericTableEnd
答案1
好吧,这更像是一种“解决方法”,但我所做的是:我找到了用于另一个表格的电子表格,转换似乎成功了。我将工作电子表格的格式复制并粘贴到无法正常工作的电子表格中,这样就解决了问题。列宽看起来不错。但是,我无法在 .tex 文件中找出问题所在;我猜那不是显而易见的东西,比如行高?这发生了很大变化。
答案2
我从未使用过 Lyx 或 Gnumeric 生成的表格。我也不太明白为什么有人会使用自动生成的代码,如果tabular
像下面这样的简单代码就可以正常工作:
\begin{tabular}{*{13}{l}}
\textbf{Name} &\textbf{Jan} &\textbf{Feb} &\textbf{Mar} &\textbf{Apr} &\textbf{May} &\textbf{Jun}
&\textbf{Jul} &\textbf{Aug} &\textbf{Sep} &\textbf{Oct} &\textbf{Nov} &\textbf{Dec} \\
Puerto Colombia & 3.14227 & 3.622 & 2.734 & 1.219 & 0.1477 & 0.143
& 0.354 & 0.086 & 0.001 & 0.001 & 0.153 & 1.51 \\
Port of Rotterdam & 1.81305 & 0.975 & 0.354 & 0.089 & 0.0613 & 0.032
& 0.027 & 0.045 & 0.195 & 0.77 & 0.995 & 1.45 \\
South Golden Beach & 0.25007 & 0.24 & 0.283 & 0.22 & 0.2363 & 0.279
& 0.345 & 0.279 & 0.303 & 0.387 & 0.328 & 0.311 \\
Katsuura & 0.94642 & 0.882 & 0.803 & 0.427 & 0.184 & 0.052
& 0.043 & 0.012 & 0.134 & 0.311 & 0.363 & 0.68
\end{tabular}