Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8942883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:38:04+00:00 2026-06-15T11:38:04+00:00

Can I control the add.to.row command in xtable to place an \footnote{} in the

  • 0

Can I control the add.to.row command in xtable to place an \footnote{} in the LaTeX table output header?

This is how far I’ve gotten it. (I would like to find a solution using xtable and not `Hmisc’)

require(xtable)
x <- matrix(rnorm(60), ncol = 10)
x.big <- xtable(x,label='tabbig', caption='Example of longtable')
names(x.big) <- LETTERS[1:10]
print(x.big,tabular.environment='longtable',floating=FALSE, 
      add.to.row = list(pos = list(seq(1,nrow(x.big), by = 2), 0, 1),
      command = c("\\rowcolor[gray]{.95} ", "\\hline \\endhead ", 
      "\\footnote{This is the first footnote that I would like to have 
      in the headder next to `I'.}") ) )

then I use the output in a small latex file. Like this:

\documentclass{article}
\usepackage{longtable} 
\usepackage{colortbl} 
\usepackage[landscape]{geometry}

\begin{document}
I
\vspace{100 mm}

% latex table generated in R 2.15.1 by xtable 1.7-0 package
% Sun Dec  2 15:38:26 2012
\begin{longtable}{rrrrrrrrrrr}
  \hline
 & A & B & C & D & E & F & G & H & I & J \\ 
  \hline \endhead  \hline
1 & 0.57 & -0.21 & 1.11 & 0.15 & -0.47 & 0.77 & 0.26 & 2.08 & 0.65 & -1.62 \\ 
   \rowcolor[gray]{.95}  \footnote{This is the first footnote that I would like to have in the headder next to `I'.}2 & -0.45 & -0.06 & 0.13 & 0.20 & 0.26 & 0.48 & 0.07 & 0.45 & -0.51 & 1.26 \\ 
  3 & -0.23 & -0.68 & 0.17 & -0.92 & -0.44 & -0.43 & -0.63 & 1.84 & 0.08 & 1.21 \\ 
   \rowcolor[gray]{.95} 4 & -1.60 & -0.69 & -0.11 & 2.12 & -0.12 & -1.81 & -1.51 & 0.67 & 0.22 & 0.43 \\ 
  5 & -0.26 & 0.14 & 0.86 & -0.78 & -2.04 & 1.17 & -1.48 & -0.38 & 0.80 & 1.49 \\ 
   \rowcolor[gray]{.95} 6 & -0.53 & -0.43 & -0.84 & 0.06 & -0.87 & 1.13 & -0.56 & 0.30 & -0.96 & 1.75 \\ 
   \hline
\hline
\caption{'Example of longtable'}
\label{tabbig}
\end{longtable}

\end{document}

This produces this table,

table01

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:38:06+00:00Added an answer on June 15, 2026 at 11:38 am

    I think you can’t manipulate the header using the add.to.row argument.

    But why not to sanitize?

    Here my solution : The idea is to put a tag in the header (footnote here) and to change it using sanitize option.

    x <- matrix(rnorm(60), ncol = 10)
    x.big <- xtable(x,label='tabbig', caption='Example of longtable')
    names(x.big) <- LETTERS[1:10]
    names(x.big)[9] <- paste('I','footnote')    # I put the tag on I letter 
    print(x.big,tabular.environment='longtable',floating=FALSE,
          sanitize.text.function=function(str)gsub("footnote","\\footnote{my tricky footnote !!}",str,fixed=TRUE))
    

    You can easily extend the solution to many footnots by using many tags.

    enter image description here

    Update , case of multiple footnote

    You can easily use thes ame trick for multiple notes, like this :

    names(x.big)[1] <- paste('A','footnote1')    # I put the tag on A letter 
    names(x.big)[9] <- paste('I','footnote2')    # I put the tag on I letter 
    print(x.big,floating=FALSE,
          sanitize.text.function=function(str){
            str <- gsub("footnote1","\\footnote{my tricky footnote 1 !!}",str,fixed=TRUE)
            str <- gsub("footnote2","\\footnote{my tricky footnote 2 !!}",str,fixed=TRUE)
          }
            )
    

    The idea is to assign the same string after the regular expression substitution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I add new method to aspxclienttextbox control? I'm doing custom control on the
When you add a DateTimePicker control, you can select part of the control value
Can any body tell me how to add silverlight 3.0 control in master page
I have a problem with WPF Toolkit Chart Control. I can't add text values
runat=server /> But this code is not working How can I add multiple controls
I have a table row that is dynamically created, so I have no control
I have a grid view, where user can add a new row. On the
Possible Duplicate: Add table row in jQuery I want to add a new row
I'm trying to add some rows to a table control in my updatepanel. I
I want to add some class to row when I render a table, sample

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.