Main Content

Link

Insert linking anchors or pointers into report

Description

This component inserts linking anchors or pointers into the report.

For a PDF report, if you open the report from MATLAB® (for example, if you open the report right after generating it), the link does not work. However, if you open a PDF report outside of MATLAB (for example, from Adobe® Acrobat®), the link works properly.

Properties

  • Link type: Select the type of link to insert into the report. Options include:

    • Linking anchor: Specifies a link to an anchor.

    • Internal document link: Specifies a location in the report (as specified by an anchor).

    • URL (external) link: Specifies a link to a Web site or to a MATLAB command to execute from generated report.

  • Link identifier: Indicates the location to which the link points. It can contain only ASCII characters, and it is not visible in the generated report.

    For a Web link, the link identifier options are context sensitive; their formats differ depending on the link type you select. For example, to link to an external file foo.txt, specify the link identifier as follows:

    • On UNIX® systems:

      file:///home/janedoe/foo.txt 
      

    • On Microsoft® Windows® systems:

      H:\foo.txt 
      

    For a link to a MATLAB command, enter matlab: followed by a space and the MATLAB command that you want the link to execute.

  • Link text: Specifies text to use in the link.

  • Emphasize link text: Italicizes the link text.

Examples

Link to an External Web Site

  1. Open Report Explorer with the setedit command.

  2. In the Properties pane on the right, click Create and edit a new Report file.

  3. In the Library pane in the middle, under the Formatting category, select the Text component and click the Add component to current report icon.

  4. In the Properties pane, enter Open the (add a blank space at the end of the text).

  5. In the Library pane, under the Formatting category, select the Link component and click the Add component to current report icon.

  6. In the Properties pane:

    • Set Link type to URL (external) link.

    • In Link Identifier, enter https://www.mathworks.com.

    • In Link text, enter MathWorks Web site.

    Report Explorer with Link component selected in the Library pane. In the Properties pane Link type is set to URL (external) link, Link identifier is set to https://wwwlmathworks.com, and Link text is set to MathWorks Web site.

  7. Generate the report.

    HTML version of the generated report, linking to the MathWorks website

  8. Click the link to open the MathWorks® website.

Link to Another Place in a Report

  1. At the MATLAB command line, enter setedit magic-square.rpt.

  2. In the Outline pane on the left, select the Title Page component.

  3. In the Library pane in the middle, under the Formatting category, select the Link component and click the Add component to current report icon.

  4. In the Properties pane:

    • Set Link type to Linking anchor.

    • In Link identifier, enter explanation.

    In the Contents pane, the Link component appears as Anchor - explanation.

  5. In the Outline pane, under the second Chapter component, select the Eval component.

  6. In the Library pane, under the Formatting category, select the Paragraph component and click the Add component to current report icon.

  7. In the Library pane, under the Formatting category, select the Link component and click the Add component to current report icon.

  8. In the Properties pane:

    • Set Link type to Internal document link.

    • In Link identifier, enter explanation.

    • In Link text, enter For a detailed explanation, click here.

    Report Explorer displaying the Properties pane with Link type set to Internal document link, Link identifier set to explanation, and Link text set to For a detailed explanation, click here.

  9. Generate the report.

    Sample of report with link to another location within the report

  10. Click the link to move to near the top of the report, to “Chapter 1. Magic Squares Explained.”

Link to a Model

This example shows how to add a link from a report to a Simulink® model. To create and run this report, you must have Simulink installed.

  1. Open Report Explorer with the setedit command.

  2. In the report library, under data (\examples\rptgenext), select simulink-default.rpt and open it.

  3. From the component library, under Formatting, select the Paragraph component and add it to your report setup file after the Model Loop Chapter component.

  4. Add a Link component after the new Paragraph component. Set these properties:

    • Set Link type to URL (external) link.

    • In Link Identifier, enter matlab:open_system('%<RptgenSL.getReportedModel()>').

    • In Link text, enter Open model.

  5. Generate the report.

    Sample report with a list of tables at the top, followed by Chapter 1, f14, which has a link to open a model

  6. To open the model from the report, click the link.

Insert Anything into Report?

Yes. Text or anchor.

Class

rptgen.cfr_link