可以使用条件脚注吗?

可以使用条件脚注吗?

我们希望使用 R 中的 xtable 创建生产 Latex 表。每个表将根据表中的某些数据具有不同的脚注。

例如,在下表中,我不想在 NAICS_TITLE 后手动输入脚注,而是想要类似 (if text="NAICS_TITLE" {footnote=("INDUSTRY")}) 这样的操作可能吗?

\documentclass{article}

% needed to modify the table margins
\usepackage[top=.5in,bottom=1in,left=.25in,right=.25in]{geometry}

% needed to generate tables longer than 1 page
\usepackage{longtable}

% needed to include footnotes in captions
\usepackage[singlelinecheck=false]{caption}

% endnotes uses so that they display at the end of the table instead of the page
\usepackage{endnotes}
\let\footnote=\endnote

\begin{document}

% Table created by stargazer v.5.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Thu, Nov 19, 2015 - 11:26:01 AM
\begin{longtable}{@{\extracolsep{-5pt}} llllllll} 
\caption{Incidence rates\protect\footnote{rates footnote} of nonfatal occupational injuries and illnesses by industry and case types, 2014} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
NAICS\_TITLE \footnote{Industry footnote} & OWNERSHIP & TEI\footnote{NAICS footnote} & TRC & CDART & CDAFW\footnote{DAFW footnote} & CDJTR & CORC \\ 
\hline \\[-1.8ex]
All industries including private, state and local\footnote{All industries footnote} & $0$ & 000000 & $3.400$ & $1.800$ & $1.100$ & $0.700$ & $1.600$ \\ 
All private industries & $50$ & 000000 & $3.200$ & $1.700$ & $1$ & $0.700$ & $1.500$ \\ 
   Goods producing & $50$ & GP1AAA & $3.800$ & $2.200$ & $1.100$ & $1$ & $1.700$ \\ 
   Natural resources and mining & $50$ & GP1NRM & $3.800$ & $2.300$ & $1.300$ & $1$ & $1.500$ \\ 
   Agriculture forestry fishing and hunting\footnote{farming footnote} & $50$ & GP2AFH & $5.500$ & $3.300$ & $1.800$ & $1.500$ & $2.200$ \\ 
   Crop production & $50$ & 111000 & $5.500$ & $3.300$ & $1.600$ & $1.700$ & $2.300$ \\ 
   Animal production and aquaculture & $50$ & 112000 & $7.100$ & $4.400$ & $2.500$ & $1.900$ & $2.700$ \\ 
   Forestry and logging & $50$ & 113000 & $5.100$ & $2.100$ & $1.900$ & $0.200$ & $2.900$ \\ 
   Fishing hunting and trapping & $50$ & 114000 & $4.900$ & $4.100$ & $$ & $0.300$ & $0.800$ \\ 
   Agriculture and forestry support activities & $50$ & 115000 & $4.500$ & $2.700$ & $1.400$ & $1.300$ & $1.800$ \\ 
   Mining quarrying and oil and gas extraction\footnote{mining footnote} & $50$ & GP2MIN & $2$ & $1.300$ & $0.800$ & $0.400$ & $0.700$ \\ 
   Oil and gas extraction & $50$ & 211000 & $$ & $0.800$ & $0.600$ & $0.200$ & $0.500$ \\ 
   Mining except oil and gas & $50$ & 212000 & $2.800$ & $1.900$ & $1.400$ & $0.500$ & $0.900$ \\ 
   Support activities for mining & $50$ & 213000 & $1.800$ & $1.100$ & $0.700$ & $0.500$ & $0.700$ \\ 
   Construction & $50$ & GP1CON & $3.600$ & $2$ & $1.300$ & $0.600$ & $1.600$ \\ 
   Construction & $50$ & GP2CON & $3.600$ & $2$ & $1.300$ & $0.600$ & $1.600$ \\ 
   Construction of buildings & $50$ & 236000 & $3.300$ & $1.900$ & $1.300$ & $0.600$ & $1.400$ \\ 
   Heavy and civil engineering construction & $50$ & 237000 & $3$ & $1.700$ & $1.100$ & $0.700$ & $1.300$ \\ 
   Specialty trade contractors & $50$ & 238000 & $3.800$ & $2$ & $1.400$ & $0.600$ & $1.800$ \\ 
   Manufacturing & $50$ & GP1MFG & $4$ & $2.200$ & $1$ & $1.200$ & $1.700$ \\ 
   Manufacturing & $50$ & GP2MFG & $4$ & $2.200$ & $1$ & $1.200$ & $1.700$ \\ 
   Food manufacturing & $50$ & 311000 & $5.100$ & $3.300$ & $1.300$ & $2$ & $1.800$ \\ 
   Beverage and tobacco product manufacturing & $50$ & 312000 & $6$ & $4$ & $1.600$ & $2.300$ & $2$ \\ 
   Textile mills & $50$ & 313000 & $3.200$ & $1.700$ & $0.700$ & $1$ & $1.500$ \\ 
   Textile product mills & $50$ & 314000 & $3.500$ & $2.100$ & $1$ & $1.100$ & $1.400$ \\ 
   Apparel manufacturing & $50$ & 315000 & $1.500$ & $0.800$ & $0.400$ & $0.500$ & $0.700$ \\ 
   Leather and allied product manufacturing & $50$ & 316000 & $3.900$ & $2.200$ & $1$ & $1.100$ & $1.700$ \\ 
   Wood product manufacturing & $50$ & 321000 & $6.800$ & $3.800$ & $1.900$ & $1.800$ & $3$ \\ 
   Paper manufacturing & $50$ & 322000 & $2.900$ & $1.700$ & $0.900$ & $0.900$ & $1.100$ \\ 
   Printing and related support activities & $50$ & 323000 & $2.500$ & $1.500$ & $0.800$ & $0.700$ & $1$ \\ 
   Petroleum and coal products manufacturing & $50$ & 324000 & $1.700$ & $0.800$ & $0.500$ & $0.300$ & $0.900$ \\ 
   Chemical manufacturing & $50$ & 325000 & $2.300$ & $1.400$ & $0.700$ & $0.700$ & $0.900$ \\ 
   Plastics and rubber products manufacturing & $50$ & 326000 & $4.600$ & $2.700$ & $1.300$ & $1.500$ & $1.900$ \\ 
   Nonmetallic mineral product manufacturing & $50$ & 327000 & $5.100$ & $3.200$ & $1.700$ & $1.500$ & $2$ \\ 
   Primary metal manufacturing & $50$ & 331000 & $5.200$ & $2.900$ & $1.200$ & $1.600$ & $2.300$ \\ 
   Fabricated metal product manufacturing & $50$ & 332000 & $4.800$ & $2.400$ & $1.300$ & $1.200$ & $2.400$ \\ 
   Machinery manufacturing & $50$ & 333000 & $3.800$ & $1.900$ & $0.900$ & $1$ & $1.900$ \\ 
   Computer and electronic product manufacturing & $50$ & 334000 & $1.300$ & $0.700$ & $0.400$ & $0.300$ & $0.600$ \\ 
   Electrical equipment and appliance mfg. & $50$ & 335000 & $3$ & $1.800$ & $0.800$ & $1$ & $1.300$ \\ 
   Transportation equipment manufacturing & $50$ & 336000 & $4.700$ & $2.600$ & $1$ & $1.600$ & $2.100$ \\ 
   Furniture and related product manufacturing & $50$ & 337000 & $4.800$ & $2.600$ & $1.200$ & $1.400$ & $2.200$ \\ 
   Miscellaneous manufacturing & $50$ & 339000 & $2.500$ & $1.400$ & $0.700$ & $0.700$ & $1.100$ \\ 
   Service providing & $50$ & SP1AAA & $3$ & $1.600$ & $0.900$ & $0.600$ & $1.400$ \\ 
   Trade transportation and utilities & $50$ & SP1TTU & $3.600$ & $2.200$ & $1.300$ & $1$ & $1.400$ \\ 
   Wholesale trade & $50$ & SP2WHT & $2.900$ & $1.900$ & $1.100$ & $0.900$ & $1$ \\ 
   Merchant wholesalers durable goods & $50$ & 423000 & $2.600$ & $1.600$ & $0.900$ & $0.700$ & $1$ \\ 
   Merchant wholesalers nondurable goods & $50$ & 424000 & $3.900$ & $2.800$ & $1.500$ & $1.300$ & $1.100$ \\ 
   Electronic markets and agents and brokers & $50$ & 425000 & $1.600$ & $1.100$ & $0.700$ & $$ & $0.500$ \\ 
   Retail trade & $50$ & SP2RET & $3.600$ & $2$ & $1$ & $1$ & $1.600$ \\ 
   Motor vehicle and parts dealers & $50$ & 441000 & $3.400$ & $1.700$ & $1$ & $0.700$ & $1.700$ \\ 
   Furniture and home furnishings stores & $50$ & 442000 & $3.900$ & $2.300$ & $1.500$ & $0.800$ & $1.600$ \\ 
   Electronics and appliance stores & $50$ & 443000 & $1.400$ & $0.800$ & $0.600$ & $0.200$ & $0.600$ \\ 
   Building material and garden supply stores & $50$ & 444000 & $5$ & $3.400$ & $1.600$ & $1.800$ & $1.600$ \\ 
   Food and beverage stores & $50$ & 445000 & $4.400$ & $2.600$ & $1.400$ & $1.200$ & $1.700$ \\ 
   Health and personal care stores & $50$ & 446000 & $2.100$ & $0.900$ & $0.600$ & $0.300$ & $1.300$ \\ 
   Gasoline stations & $50$ & 447000 & $2.300$ & $1.100$ & $0.600$ & $0.500$ & $1.200$ \\ 
   Clothing and clothing accessories stores & $50$ & 448000 & $2$ & $0.700$ & $0.400$ & $0.300$ & $1.400$ \\ 
   Sporting goods hobby book and music stores & $50$ & 451000 & $2.600$ & $1.100$ & $0.600$ & $0.500$ & $1.400$ \\ 
   General merchandise stores & $50$ & 452000 & $4.800$ & $2.800$ & $1.200$ & $1.600$ & $2$ \\ 
   Miscellaneous store retailers & $50$ & 453000 & $3.400$ & $1.700$ & $1$ & $0.700$ & $1.700$ \\ 
   Nonstore retailers & $50$ & 454000 & $1.800$ & $1.200$ & $0.600$ & $0.500$ & $0.700$ \\ 
   Transportation and warehousing & $50$ & SP2TRW & $4.800$ & $3.400$ & $2.300$ & $1.200$ & $1.400$ \\ 
   Air transportation & $50$ & 481000 & $7.500$ & $6.100$ & $4.500$ & $1.600$ & $1.300$ \\ 
   Rail transportation & $50$ & 482000 & $2$ & $1.500$ & $1.300$ & $0.100$ & $0.500$ \\ 
   Water transportation & $50$ & 483000 & $2.300$ & $1.400$ & $0.900$ & $0.600$ & $0.900$ \\ 
   Truck transportation & $50$ & 484000 & $4.500$ & $3.200$ & $2.300$ & $0.900$ & $1.300$ \\ 
   Transit and ground passenger transportation & $50$ & 485000 & $4.600$ & $3.200$ & $2.400$ & $0.800$ & $1.400$ \\ 
   Pipeline transportation & $50$ & 486000 & $1.800$ & $0.800$ & $0.600$ & $0.200$ & $0.900$ \\ 
   Scenic and sightseeing transportation & $50$ & 487000 & $3.200$ & $2.400$ & $1.900$ & $0.600$ & $0.800$ \\ 
   Support activities for transportation & $50$ & 488000 & $3.600$ & $2.200$ & $1.500$ & $0.800$ & $1.400$ \\ 
   Couriers and messengers & $50$ & 492000 & $7.100$ & $5.200$ & $3.100$ & $2.200$ & $1.800$ \\ 
   Warehousing and storage & $50$ & 493000 & $5.200$ & $3.700$ & $1.700$ & $1.900$ & $1.500$ \\ 
   Utilities & $50$ & SP2UTL & $2.400$ & $1.300$ & $0.700$ & $0.600$ & $1.200$ \\ 
   Utilities & $50$ & 221000 & $2.400$ & $1.300$ & $0.700$ & $0.600$ & $1.200$ \\ 
   Information & $50$ & SP1INF & $1.400$ & $0.800$ & $0.600$ & $0.200$ & $0.600$ \\ 
   Information & $50$ & SP2INF & $1.400$ & $0.800$ & $0.600$ & $0.200$ & $0.600$ \\ 
   Publishing industries except internet & $50$ & 511000 & $1$ & $0.400$ & $0.300$ & $0.100$ & $0.600$ \\ 
   Motion picture and sound recording industries & $50$ & 512000 & $1.600$ & $0.600$ & $0.400$ & $0.200$ & $1$ \\ 
   Broadcasting except internet & $50$ & 515000 & $1.400$ & $0.600$ & $0.400$ & $0.200$ & $0.700$ \\ 
   Telecommunications & $50$ & 517000 & $2.200$ & $1.600$ & $1.300$ & $0.300$ & $0.600$ \\ 
   Data processing hosting and related services & $50$ & 518000 & $0.500$ & $0.200$ & $0.200$ & $0.100$ & $0.300$ \\ 
   Other information services & $50$ & 519000 & $0.400$ & $0.200$ & $$ & $0$ & $0.200$ \\ 
   Financial activities & $50$ & SP1FIA & $1.200$ & $0.500$ & $0.400$ & $0.200$ & $0.700$ \\ 
   Finance and insurance & $50$ & SP2FIN & $0.700$ & $0.200$ & $0.200$ & $0$ & $0.400$ \\ 
   Monetary authorities - central bank & $50$ & 521000 & $1$ & $0.500$ & $0.300$ & $0.200$ & $0.500$ \\ 
   Credit intermediation and related activities & $50$ & 522000 & $0.800$ & $0.300$ & $0.200$ & $0.100$ & $0.500$ \\ 
   Securities commodity contracts investments & $50$ & 523000 & $0.200$ & $0.100$ & $0.100$ & $0$ & $0.100$ \\ 
   Insurance carriers and related activities & $50$ & 524000 & $0.600$ & $0.200$ & $0.200$ & $0$ & $0.400$ \\ 
   Real estate and rental and leasing & $50$ & SP2RRL & $2.900$ & $1.500$ & $0.900$ & $0.600$ & $1.400$ \\ 
   Real estate & $50$ & 531000 & $2.500$ & $1.300$ & $0.900$ & $0.400$ & $1.200$ \\ 
   Rental and leasing services & $50$ & 532000 & $4$ & $1.900$ & $0.900$ & $1$ & $2.100$ \\ 
   Lessors of nonfinancial intangible assets & $50$ & 533000 & $1$ & $0.200$ & $0.100$ & $$ & $0.800$ \\ 
   Professional and business services & $50$ & SP1PBS & $1.500$ & $0.800$ & $0.500$ & $0.300$ & $0.700$ \\ 
   Professional and technical services & $50$ & SP2PST & $0.900$ & $0.400$ & $0.300$ & $0.100$ & $0.600$ \\ 
   Professional and technical services & $50$ & 541000 & $0.900$ & $0.400$ & $0.300$ & $0.100$ & $0.600$ \\ 
   Management of companies and enterprises & $50$ & SP2MCE & $1$ & $0.500$ & $0.300$ & $0.200$ & $0.500$ \\ 
   Administrative and waste services & $50$ & SP2ADW & $2.600$ & $1.600$ & $1.100$ & $0.500$ & $1.100$ \\ 
   Administrative and support services & $50$ & 561000 & $2.400$ & $1.400$ & $1$ & $0.400$ & $1$ \\ 
   Waste management and remediation services & $50$ & 562000 & $5.100$ & $3.400$ & $2.200$ & $1.200$ & $1.700$ \\ 
   Educational and health services & $50$ & SP1EHS & $4.200$ & $2$ & $1.100$ & $0.800$ & $2.200$ \\ 
   Educational services & $50$ & SP2EDS & $2.100$ & $0.900$ & $0.600$ & $0.200$ & $1.200$ \\ 
   Educational services & $50$ & 611000 & $2.100$ & $0.900$ & $0.600$ & $0.200$ & $1.200$ \\ 
   Health care and social assistance & $50$ & SP2HSA & $4.500$ & $2.100$ & $1.200$ & $0.900$ & $2.400$ \\ 
   Ambulatory health care services & $50$ & 621000 & $2.400$ & $0.900$ & $0.600$ & $0.300$ & $1.500$ \\ 
   Hospitals & $50$ & 622000 & $6.200$ & $2.500$ & $1.500$ & $1$ & $3.700$ \\ 
   Nursing and residential care facilities & $50$ & 623000 & $7.100$ & $4.300$ & $2$ & $2.300$ & $2.800$ \\ 
   Social assistance & $50$ & 624000 & $3.500$ & $1.800$ & $1.300$ & $0.600$ & $1.600$ \\ 
   Leisure and hospitality & $50$ & SP1LEH & $3.600$ & $1.500$ & $1$ & $0.600$ & $2.100$ \\ 
   Arts entertainment and recreation & $50$ & SP2AER & $4.200$ & $2.100$ & $1.200$ & $0.900$ & $2.100$ \\ 
   Performing arts and spectator sports & $50$ & 711000 & $4.700$ & $2.200$ & $1.500$ & $0.700$ & $2.500$ \\ 
   Museums historical sites zoos and parks & $50$ & 712000 & $4$ & $2$ & $1.200$ & $0.800$ & $2$ \\ 
   Amusements gambling and recreation & $50$ & 713000 & $4.100$ & $2.100$ & $1.100$ & $0.900$ & $2$ \\ 
   Accommodation and food services & $50$ & SP2AFS & $3.500$ & $1.400$ & $0.900$ & $0.500$ & $2.100$ \\ 
   Accommodation & $50$ & 721000 & $4.900$ & $2.700$ & $1.400$ & $1.200$ & $2.300$ \\ 
   Food services and drinking places & $50$ & 722000 & $3.200$ & $1.200$ & $0.800$ & $0.300$ & $2$ \\ 
   Other services except public administration & $50$ & SP1OTS & $2.500$ & $1.200$ & $0.900$ & $0.400$ & $1.200$ \\ 
   Other services except public administration & $50$ & SP2OTS & $2.500$ & $1.200$ & $0.900$ & $0.400$ & $1.200$ \\ 
   Repair and maintenance & $50$ & 811000 & $3$ & $1.400$ & $1$ & $0.400$ & $1.600$ \\ 
   Personal and laundry services & $50$ & 812000 & $2.200$ & $1.400$ & $0.900$ & $0.500$ & $0.800$ \\ 
   Membership associations and organizations & $50$ & 813000 & $2$ & $0.900$ & $0.600$ & $0.200$ & $1.100$ \\ 
State and local government & $10$ & 000000 & $5$ & $2.300$ & $1.700$ & $0.600$ & $2.700$ \\ 
State government & $20$ & 000000 & $4.100$ & $2.100$ & $1.700$ & $0.400$ & $2$ \\ 
   Service providing & $20$ & SP1AAA & $4.100$ & $2.100$ & $1.700$ & $0.400$ & $2$ \\ 
   Educational and health services & $20$ & SP1EHS & $3.700$ & $1.900$ & $1.400$ & $0.500$ & $1.900$ \\ 
   Educational services & $20$ & SP2EDS & $2.100$ & $0.900$ & $0.600$ & $0.300$ & $1.300$ \\ 
   Educational services & $20$ & 611000 & $2.100$ & $0.900$ & $0.600$ & $0.300$ & $1.300$ \\ 
   Health care and social assistance & $20$ & SP2HSA & $8.100$ & $4.600$ & $3.600$ & $1$ & $3.500$ \\ 
   Hospitals & $20$ & 622000 & $8.700$ & $4.700$ & $3.600$ & $1.100$ & $4$ \\ 
   Nursing and residential care facilities & $20$ & 623000 & $12.600$ & $7.900$ & $6.200$ & $1.700$ & $4.600$ \\ 
   Public administration & $20$ & SP1PAD & $4.400$ & $2.300$ & $1.900$ & $0.400$ & $2.100$ \\ 
   Public administration & $20$ & SP2PAD & $4.400$ & $2.300$ & $1.900$ & $0.400$ & $2.100$ \\ 
   Justice public order and safety activities & $20$ & 922000 & $6.100$ & $3.300$ & $2.700$ & $0.500$ & $2.800$ \\ 
Local government & $30$ & 000000 & $5.400$ & $2.300$ & $1.700$ & $0.700$ & $3$ \\ 
   Goods producing & $30$ & GP1AAA & $8.600$ & $4.200$ & $3$ & $1.300$ & $4.300$ \\ 
   Construction & $30$ & GP1CON & $8.600$ & $4.200$ & $3$ & $1.300$ & $4.400$ \\ 
   Construction & $30$ & GP2CON & $8.600$ & $4.200$ & $3$ & $1.300$ & $4.400$ \\ 
   Heavy and civil engineering construction & $30$ & 237000 & $8.600$ & $4.200$ & $2.900$ & $1.300$ & $4.300$ \\ 
   Service providing & $30$ & SP1AAA & $5.300$ & $2.300$ & $1.700$ & $0.700$ & $3$ \\ 
   Trade transportation and utilities & $30$ & SP1TTU & $6.500$ & $3.600$ & $2.700$ & $0.800$ & $2.900$ \\ 
   Transportation and warehousing & $30$ & SP2TRW & $7.500$ & $4.500$ & $4$ & $0.500$ & $3$ \\ 
   Transit and ground passenger transportation & $30$ & 485000 & $7.100$ & $4.400$ & $4$ & $0.400$ & $2.700$ \\ 
   Utilities & $30$ & SP2UTL & $5.400$ & $2.700$ & $1.500$ & $1.200$ & $$ \\ 
   Utilities & $30$ & 221000 & $5.400$ & $2.700$ & $1.500$ & $1.200$ & $$ \\ 
   Educational and health services & $30$ & SP1EHS & $4.300$ & $1.600$ & $1.100$ & $0.500$ & $2.700$ \\ 
   Educational services & $30$ & SP2EDS & $4.100$ & $1.500$ & $1$ & $0.500$ & $2.600$ \\ 
   Educational services & $30$ & 611000 & $4.100$ & $1.500$ & $1$ & $0.500$ & $2.600$ \\ 
   Health care and social assistance & $30$ & SP2HSA & $5.600$ & $2.400$ & $1.600$ & $0.800$ & $3.200$ \\ 
   Hospitals & $30$ & 622000 & $5.700$ & $2.200$ & $1.400$ & $0.800$ & $3.600$ \\ 
   Nursing and residential care facilities & $30$ & 623000 & $7.400$ & $5.200$ & $3.500$ & $1.600$ & $2.300$ \\ 
   Public administration & $30$ & SP1PAD & $7.100$ & $3.400$ & $2.500$ & $0.900$ & $3.700$ \\ 
   Public administration & $30$ & SP2PAD & $7.100$ & $3.400$ & $2.500$ & $0.900$ & $3.700$ \\ 
   Justice public order and safety activities & $30$ & 922000 & $9.500$ & $4.800$ & $3.900$ & $0.900$ & $4.700$ \\ 
\hline \\[-1.8ex] 

\end{longtable}
\theendnotes
\end{document}

答案1

etoolbox包提供了一个字符串相等性测试,可以像\cfootnote下面的宏一样使用。如果您愿意从相关单元格调用宏,如下面的第一个示例所示,那么将根据单元格值添加脚注。请注意%宏行末尾的,以防止在宏扩展期间出现不必要的空格等。

如果您想自动添加脚注而不编写重复的宏调用,那么您可以使用包collcell定义一个包含宏调用的新列类型,如下面的第二个示例所示。请注意,longtable和之间似乎存在不兼容性,这会导致错误,可以通过向表中添加基本类型的虚拟列(以及在每一行中添加一个额外的列,以及在空行中添加序列)collcell来解决此问题。&&

此外,我还使用了caption包和footnotemarkfootnotetext修复脚注编号问题。

梅威瑟:

\documentclass{article}
\usepackage{longtable}
\usepackage{etoolbox}
\usepackage{collcell}
\usepackage{caption}

\newcommand*{\cfootnote}[1]{%
          #1%
          \ifstrequal{#1}{NAICS\_TITLE}{\footnote{Industry footnote}}{%
                \ifstrequal{#1}{TEI}{\footnote{NAICS footnote}}{%
                \ifstrequal{#1}{CDAFW}{\footnote{DAFW footnote}}{}%
            }%
        }%
}
\newcolumntype{L}{>{\collectcell\cfootnote}l<{\endcollectcell}}
%%%% First example
\begin{document}
\begin{longtable}{@{\extracolsep{-5pt}} llllllll}
\caption{First example. Incidence rates\protect\footnote{rates footnote} of nonfatal occupational injuries and illnesses by industry and case types, 2014}
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
\cfootnote{NAICS\_TITLE} & OWNERSHIP & \cfootnote{TEI} & TRC & \cfootnote{CDART} & CDAFW & CDJTR & CORC\\
\end{longtable}

%%%% Second example
\begin{longtable}{@{\extracolsep{-5pt}} LLLLLLLLr}
\caption{Second example. Incidence rates\protect\footnotemark\ of nonfatal occupational injuries and illnesses by industry and case types, 2014}\\[-1.8ex]
\footnotetext{rates footnote}&&&&&&&&\\[-1.8ex]\hline 
\hline &&&&&&&&\\[-1.8ex] 
NAICS\_TITLE & OWNERSHIP & TEI & TRC & CDART & CDAFW & CDJTR & CORC &\\
\end{longtable}
\end{document}

对于以后的问题,请提供完整的代码示例(而不是仅提供表中的几行)。

此解决方案使用的来源:

当参数是使用 etoolbox 命令的结果时,将参数与字符串进行比较

如何将宏应用于表格的每一列

collcell、longtable 和/或 arydshln 之间是否存在不兼容性?

如何在长表顶部添加标题?


编辑:关于自动添加额外内容&:这可能是 R 中最简单的。例如:

library(xtable)
# data frame
df <- data.frame(A = c(1,2,3), B = c(4,5,6), DUMMY = character(3))
colnames(df)[3] <- ""
xtable(df)
# with some xtable options
print.xtable(xtable(df, display = c("s","d","d","s"), align="LLLr"),include.rownames=FALSE, floating=FALSE, tabular.environment='longtable')

# matrix
df2 <- matrix(c(c(1,2,3,4,5,6),character(3)),nrow=3,ncol=3,byrow=FALSE)
dimnames(df2) = list(character(3),c("A","B","DUMMY"))
colfunc <- function(col) { sub("DUMMY","",col) }
print.xtable(xtable(df2),sanitize.colnames.function=colfunc)

注意:xtable替换矩阵中的空列名,可以通过使用选项删除列名来解决此问题sanitize

关于重复的脚注:该fixfoot软件包非常接近,它会为给定页面上的所有脚注打印单个脚注。但是,编号是递增的。或者,您可以在第一页打印所有脚注,并\footnotemark在宏中使用相应的 s。

相关内容