Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I control font size of a hyperlink in a putdocx table cell?

    I am struggling to figure out how to take control of the font size of hyperlink text in a putdocx table cell.

    Context

    I'm using putdocx to make a 2-page automated handout with an overview of survey results for stakeholders in each of 152 survey strata.

    I'm wrapping most of the content inside a putdocx table to achieve the page layout that I have in mind.

    I want to include a small note at the bottom of the page with a URL so the curious reader can access more details, footnotes, caveats, or the entire report.

    I would like to use a small font size that says: For explanatory notes, visit: https://tinyurl/etcetcetc. *and* I would like the URL to be a clickable hyperlink.

    I am struggling to figure out how to take control of the font size of the hyperlink text. I'm using the following code. I've split the note across two table cells because I only want the URL to be the hyperlink. The preface should be plain text.

    A snippet of my code

    Code:
    putdocx table page2(12,1) = ("For explanatory notes, visit:  "), colspan(3) font(,9) halign(right)
    putdocx table page2(12,2) = ("https://tinyurl.com/etcetcetc") , colspan(2) font(,9) halign(left) hyperlink("https://tinyurl.com/etcetcetc")
    This is yielding 9 pt font for the first phrase (hooray) but darn it, it is yielding 11 pt font for the URL. (11 pt is the default for the page).

    How can I render the URL in 9 point text?

    Down below you'll find an example you can run that shows the same problem. The putdocx font default is set to 20pt and we try to make the URL in cell (6,1) render as 9 pt, but it renders as 20pt.

    Of course I can change the page default to be 9pt and explicitly specify the size of everything else on the page; I think that would work. But I rather hope that won't be necessary.

    Thanks in advance for having a look.

    -Dale

    An example you can modify

    Code:
    * I'm puzzled re: how to make the hyperlink text any size other than the document default
    
    capture putdocx clear
    putdocx begin, font(Lato, 20, black) pagesize(A4) margin(all, 1in)
    
        putdocx table test = (6,1)
        
        putdocx table test(1,1) = ("...went to market..."), halign(center)
        putdocx table test(2,1) = ("...stayed home..."),    halign(center)
        putdocx table test(3,1) = ("...ate roast beef..."), halign(center)
        putdocx table test(4,1) = ("...had none..."),       halign(center)
        putdocx table test(5,1) = ("...wee, wee, wee..."),  halign(center)
    
        putdocx table test(6,1) = (" Click here for full text."), font(,9) halign(center) hyperlink("https://www.poetryfoundation.org/poems/46943/this-little-piggy")
    
    putdocx save ltp_test, replace

  • #2
    I think you should be able to change the font size with text in table analogously to a paragraph. I couldn't get -putdocx- to deviate from the page default font size. You may want to contact Stata Technical Support with this question.

    Comment

    Working...
    X