How do I center a table on the page?

12 visualizaciones (últimos 30 días)
Tyler
Tyler el 8 de Mayo de 2014
Editada: Paul Kinnucan el 13 de Mayo de 2016
Using the report generator, my tables are all aligned left but I would like them centered on the page (pdf report). How do I do this?

Respuestas (1)

Paul Kinnucan
Paul Kinnucan el 13 de Mayo de 2016
Editada: Paul Kinnucan el 13 de Mayo de 2016
Before R2104b, it is not possible to center tables.
Starting in R2014b, there are multiple ways to center a table.
  • Method 1 (works in R2014b or later)
  1. Use Micrsoft Word to customize the rgUnruledTable style to be centered in the Report Explorer's default Word template. (In R2016a or later, create a custom PDF template with a centered rgUnruledTable style.)
  2. Use the customized template and the PDF (from Word template), or PDF (from template) in R2016a or later, output type to generate your report.
  • Method 2 (works with the DOM API in 2014b or later)
  1. Create a Word template (or a PDF template in R2016a or later) that defines a centered table style.
  2. Create a DOM document object based on the Word template (or PDF template in 16a or later).
  3. Create a DOM table object.
  4. Assign the centered table style to the object.
  5. Append the table to the document.
  6. Close the document.
  7. Use rptview to convert the Word document to PDF and display it. (In 16a, no conversion is necessary. Just use rptview to display the PDF document).
  • Method 3 (works with the DOM API in 2014b or later)
  1. Create a DOM document object based on the default or a custom Word template (or default or custom PDF template in 16a or later).
  2. Create a DOM table object.
  3. Assign an HAlign('center') format to the table object.
  4. Append the table to the document.
  5. Close the document.
  6. Use rptview to convert the Word document to PDF and display it. (In 16a, no conversion is necessary. Just use rptview to display the PDF document).

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by