如何在 Stata 中为 LaTeX 创建单页频率表而不是长表?

如何在 Stata 中为 LaTeX 创建单页频率表而不是长表?

我正在使用 stata 12。我有一个非常长的频率表需要放在附录中(它由国家组成),我希望将这个表放在一页中,而不是在 LaTeX 中输出一个非常长的表格。

也就是说,不是有这样的事情(我省略了 \table 和 \tabular 环境并严格解决列问题):

    Country &  Frequency\\
    \textbf{U.S.} & 4\\
    \text{bf{U.K.} & 10\\
    \textbf{Uganda} & 7\\
    \textbf{Uzbekistan} & 2\\

...

像这样:

    Country & Frequency & Country & Frequency & Country & Frequency & Country & Frequency\\
   \textbf{U.S.} & 4 & \text{bf{U.K.} & 10 & \textbf{Uganda} & 7 & \textbf{Uzbekistan} & 2\\

...

从理论上来说这更加经济。

答案1

您可以使用pgfplotstable分离数据和表格格式

\documentclass{article}
\usepackage{pgfplotstable,booktabs}
% Just make a table of things
% It doesn't have to be in the preamble
% but just to show the idea, it's moved to here
\pgfplotstableread[col sep=comma]{
country, freq
Afghanistan            ,AF      
Aland Islands          ,AX      
Albania                ,AL      
Algeria                ,DZ      
American Samoa         ,AS      
Andorra                ,AD      
Angola                 ,AO      
Anguilla               ,AI      
Antigua and Barbuda    ,AG      
Argentina              ,AR      
Armenia                ,AM      
Aruba                  ,AW      
Australia              ,AU      
Austria                ,AT      
Azerbaijan             ,AZ      
Bahrain                ,BH      
Bangladesh             ,BD      
Barbados               ,BB      
Belarus                ,BY      
Belgium                ,BE      
Belize                 ,BZ      
Benin                  ,BJ      
Bermuda                ,BM      
Bhutan                 ,BT      
Bolivia                ,BO      
Bosnia and Herzegovina ,BA      
Botswana               ,BW      
Brazil                 ,BR      
}\mycountryfreqtable
% Now the data is in the \mycountryfreqtable
% in the form of pgfplotstable format


\begin{document}

% This starts typesetting the table
\pgfplotstabletypeset[% Put some settings about the rules etc.
every head row/.style={before row=\toprule,after row=\midrule},
every last row/.style={after row=\bottomrule},
% Now insert as many column pairs as you want
% I want 3 groups of columns so repeated thrice
columns={country,freq,country,freq,country,freq},
% Then notice that index starts from zero and I want three parts
% so the command goes 0 of 3, 1 of 3 and 2 of 3
% You don't need to understand right away why 
% just copy paste it. 
display columns/0/.style={select equal part entry of={0}{3},string type},% first part of ‘A’
display columns/1/.style={select equal part entry of={0}{3},string type},% first part of ‘B’
display columns/2/.style={select equal part entry of={1}{3},string type},% second part of ‘A’
display columns/3/.style={select equal part entry of={1}{3},string type},% second part of ‘B’
display columns/4/.style={select equal part entry of={2}{3},string type},% first part of ‘A’
display columns/5/.style={select equal part entry of={2}{3},string type},% first part of ‘B’
]% End of options
{\mycountryfreqtable}


\end{document}

在此处输入图片描述

相关内容