Hyperlinks and Latex: Centering hyperlink and knitting to pdf

Creating an R Markdown document.
Trying to get a hyperlink to center on the page.

Script:

\begin{center]
SOLUTION LINK
\end{center}

Output: It does kinda what it's supposed to. It centers the line, but strips the hyperlink and just knits the text onto the pdf.

Let me know if this sounds clear.

with the closing ] on the first line was going to be a problem all on its own, but even fixing it doesn't make centered markdown style links work right. Here's one way to do it, and you probably would need to do something similar for environments other than {center}

\newcommand{\soln}{https://forum.posit.co/t/hyperlinks-and-latex-centering-hyperlink-and-knitting-to-pdf/145171}


\begin{center}

\href{\soln}{SOLUTION LINK}

\end{center}
1 Like

SWEET!!! That worked perfectly! So happy!

1 Like

For reference, Using Markdown inside LaTeX block does not work because this is still an unsupported feature from Pandoc

that is why one need to used LaTeX between the \begin ... \end block here.

Other solution for this would be to add a Lua filter to process such syntax

::: center
[Link](to/solution)
:::

like shown in request: syntax for centering text · Issue #719 · jgm/pandoc · GitHub as there is not built-in center syntax in Pandoc yet.

Hope it helps understand

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.