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 7411271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:21:44+00:00 2026-05-29T06:21:44+00:00

Is it possible to generate a LaTeX document through Sweave that don’t have the

  • 0

Is it possible to generate a LaTeX document through Sweave that don’t have the number of its elements predefined? I mean, suppose I need to build a table for each row in a dataframe. The number of tables in the document will depend on the number of rows in the dataframe.

In other words, generate LaTeX elements inside a for loop. For each row Sweave would build a table.

The same would apply for pages, or other elements. Is it possible to do this?

  • 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-05-29T06:21:45+00:00Added an answer on May 29, 2026 at 6:21 am

    Does this help:

    \documentclass[a4paper,12pt]{article}
    \usepackage{Sweave}
    
    \begin{document}
    
    <<echo=FALSE>>=
    library( xtable )
    df <- structure(list(ID = 2:6, home_pc = structure(c(2L, 6L, 1L, 3L,
    5L), .Label = c("BY5 8IB", "CB4 2DT", "DH4 6PB", "KN4 5GH", "MP9 7GH",
    "NE5 7TH", "VB2 4RF"), class = "factor"), start_pc = structure(c(4L,
    3L, 4L, 2L, 1L), .Label = c("BV6 5PB", "CB3 5TH", "FC5 7YH",
    "Home", "NA"), class = "factor"), end_pc = structure(c(1L, 3L,
    3L, 3L, 2L), .Label = c("CB5 4FG", "GH6 8HG", "Home", "NA"), class = "factor")), .Names = c("ID",
    "home_pc", "start_pc", "end_pc"), row.names = 2:6, class = "data.frame")
    count = 1
    end = 3
    @
    
    <<fun,echo=FALSE,eval=FALSE>>=
    print( xtable( df ) )
    @
    
    
    <<echo=FALSE,results=tex>>=
    for( i in 1:end )
    {
        print( xtable( df ) )
        i <- i + 1
    }
    cat( "\\newpage" )
    @
    
    <<echo=FALSE,results=tex>>=
    if( count < end )
    <<fun>>
    count = count + 1
    cat( "\\newpage" )
    @
    
    <<echo=FALSE,results=tex>>=
    if( count < end )
    <<fun>>
    count = count + 1
    cat( "\\newpage" )
    @
    
    <<echo=FALSE,results=tex>>=
    if( count < end )
    <<fun>>
    count = count + 1
    cat( "\\newpage" )
    @
    
    \end{document}
    

    Happy to go into more details if this is the right track!

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

Sidebar

Related Questions

I have a LaTeX document that I wrote, that needs to be reviewed by
Is it possible to generate a random number between 2 doubles? Example: public double
Is it possible to take something like x^2+5 and have it generate this: https://i.stack.imgur.com/a0f8Q.gif
How to shuffle the elements in the pairs? The program below, generate all possible
I have the following need (in python): generate all possible tuples of length 12
I have a <select> list of products that I generate with PHP. I would
I'm trying to generate a long Latex document with Ruby. If I use a
I'm currently writing an API document in LaTeX. I have a tabular environment with
Back in the old days, Help was not trivial but possible: generate some funky
Is it possible to generate PDF Documents in an Adobe AIR application without resorting

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.