我正在编写一些lua
代码,将保存的表输出到文件,然后由 读取\pgfplotstableread{myfile.dat}\mytable
。我想避免两个步骤:保存到文件和用 读取。所以,我的选择是直接在侧面\pgfplotstableread
“写入” 。但我不知道 内部如何存储表格。我做了一些实验:\mytable
lua
pgfplotstable
\documentclass{article}
\usepackage{pgfplotstable}
\pgfplotstableread[col sep=comma]{
Name, Age, stDev
Adam, 15, 3
Eve, 12, 1
}\mytable
\begin{document}
\show\mytable
\end{document}
其结果是:
> \mytable=macro:
->\pgfpl@@ {Name}\pgfpl@@ {Age}\pgfpl@@ {stDev}.
所以我猜其他行存储在其他宏中。我的问题是如何存储的?
答案1
根据pgfplotstableshared.code.tex
(第 31-53 行)中的评论
% This file provides a high-level table manipulation and typesetting % package. % % % --------------------------------------------- % Implementation notes for programmers: % --------------------------------------------- % % The table data structure consists of % 1. A name which must be a valid TeX macro like '\table' % 2. A column list in the \pgfplotslist format. % In fact, the column list is stored in the table's name: % \pgfplotslistnewempty\table % 3. A "file name" stored in % \csname\string<\namemacro>@@table@name\endcsname % 4. A "scan line length" number stored in % \csname\string<\namemacro>@@table@scanline\endcsname % It contains the value of \pgfplotsscanlinelength which has % been identified right after \pgfplotstableread. % 5. foreach column, there is a list of row-values (a row-vector) in % the \pgfplotslist format named % \csname\string<\namemacro>@<column name>\endcsname %
我们可以编写以下测试
\documentclass{article}
\usepackage{pgfplotstable}
\pgfplotstableread[col sep=comma]{
Name, Age, stDev
Adam, 15, 3
Eve, 12, 1
}\mytable
\begin{document}
\begin{itemize}\makeatletter\ttfamily
\item[2] \string\mytable \\
\meaning\mytable
\item[3] file name \\
\expandafter\meaning\csname\string\mytable @@table@name\endcsname
\item[4] scan line length \\
\expandafter\meaning\csname\string\mytable @@table@scanline\endcsname
\item[5] column Name \\
\expandafter\meaning\csname\string\mytable @Name\endcsname
\item[5] column Age \\
\expandafter\meaning\csname\string\mytable @Age\endcsname
\item[5] column stDev \\
\expandafter\meaning\csname\string\mytable @stDev\endcsname
\end{itemize}
\end{document}