> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/in-depth-articles/46-testing-display-and-link-template.md).

# Testing display and link template

## Testing display and link template

NOTE: ONGOING TESTING SO RESULTS MAY "FLUCTUATE"

## MediaWiki Template to show part or all of a LaTeX document

The proposed template [Template:OpenLaTeXInOverleaf](https://github.com/ayaka-notes/overleaf-learn-wiki/tree/main/learn/Template:OpenLaTeXInOverleaf/README.md) lets you display inline LaTeX code *and*, using work by Alf, automatically generates an `Open in Overleaf` link from the inline LaTeX code—you write the code just *once*. It also allows you to display just the `body` of your LaTeX, omitting the entire preamble and \end{document}, or it will display an entire document, but in both cases a fully-formed document will be opened in Overleaf.

* Note: For reasons due to MediaWiki parsing, **you need to use `{{!}}` in your TeX code to produce the | character**.

### Parameters for controlling inline display of LaTeX code (and document construction)

* **`pre`**, which sets `preamble` of your document. It defaults to

```
\documentclass{article}
\begin{document}
```

* **`body`** which is the core code of your LaTeX document
* **`post`**, which sets end of your document. It defaults to

```
\end{document}
```

* **`show`** which controls display of your LaTeX code: either the `body` section or the whole document
  * `show=ALL` displays the entire LaTeX document---uses your values of `body`, `pre` and `post`, or uses the *defaults* for `pre` or `post`.
  * `show=BODY` displays only the body of your LaTeX code

In all cases an automatic "Open in Overleaf" link is constructed using the settings for **`pre`**, **`body`** and **`post`**

### Parameters for controlling Overleaf API call (inherited via work by Alf)

* **`engine`** set the compiler used for the code, can be one of:
  * `pdflatex` (the default if no engine is selected)
  * `xelatex`
  * `lualatex`
  * `latex_dvipdf`
* **`name`** sets the title of the Overleaf document
* **`text`** set the text used to display the link

## Examples

The following section lists some example uses of the template.

### Define pre, post and setting show=ALL

```
{{OpenLaTeXInOverleaf|show=ALL|pre=
\documentclass{book}
\begin{document}
|body=

Hello

dear

\LaTeX

|post=
\end{document}%Here we end the document
|engine=lualatex|name=Test using LuaLaTeX|text=Open a LuaLaTeX example in Overleaf
}}
```

The above code produces the following inline display and "Open in Overleaf" link

```latex
\documentclass{book}
\begin{document}
Hello

dear

\LaTeX
\end{document}%Here we end the document
```

&#x20;[Open a LuaLaTeX example in Overleaf](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Test+using+LuaLaTeX\&snip=%5Cdocumentclass%7Bbook%7D%0A%5Cbegin%7Bdocument%7D%0AHello+%0A%0Adear%0A%0A%5CLaTeX%0A%5Cend%7Bdocument%7D%25Here+we+end+the+document)

### Define pre, post and show=BODY

```
{{OpenLaTeXInOverleaf|show=BODY|pre=
\documentclass{book}
\begin{document}
|body=

Hello

dear

\LaTeX

|post=
\end{document}%Here we end the document
|engine=lualatex|name=Test using LuaLaTeX|text=Open a LuaLaTeX example in Overleaf
}}
```

The above code produces the following inline display and "Open in Overleaf" link

```latex
Hello

dear

\LaTeX
```

&#x20;[Open a LuaLaTeX example in Overleaf](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Test+using+LuaLaTeX\&snip=%5Cdocumentclass%7Bbook%7D%0A%5Cbegin%7Bdocument%7D%0AHello+%0A%0Adear%0A%0A%5CLaTeX%0A%5Cend%7Bdocument%7D%25Here+we+end+the+document)

### Define an empty pre, an empty post but a fuller body

```
{{OpenLaTeXInOverleaf|show=ALL|pre=|post=|body=

\documentclass{book}

\begin{document}

Hello

dear

\LaTeX

\end{document}
|engine=lualatex|name=Test using LuaLaTeX|text=Open a LuaLaTeX example in Overleaf
}}
```

The above code produces the following inline display and "Open in Overleaf" link

```latex
\documentclass{book}

\begin{document}

Hello

dear

\LaTeX

\end{document}
```

&#x20;[Open a LuaLaTeX example in Overleaf](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Test+using+LuaLaTeX\&snip=%5Cdocumentclass%7Bbook%7D%0A%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%0AHello+%0A%0Adear%0A%0A%5CLaTeX%0A%0A%0A%5Cend%7Bdocument%7D)

### Use defaults for pre and post but supply code for the body

```
{{OpenLaTeXInOverleaf|show=ALL|body=
Hello

dear

\LaTeX
|engine=lualatex|name=Test using LuaLaTeX|text=Open a LuaLaTeX example in Overleaf
}}
```

The above code produces the following inline display and "Open in Overleaf" link

```latex
\documentclass{article}
\begin{document}

Hello

dear

\LaTeX

\end{document}
```

&#x20;[Open a LuaLaTeX example in Overleaf](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Test+using+LuaLaTeX\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%0AHello+%0A%0Adear%0A%0A%5CLaTeX%0A%0A%5Cend%7Bdocument%7D)

## TESTING IGNORE THESE LINKS

```latex
\documentclass{article}
\begin{document}

\LaTeX

\end{document}
```

&#x20;[Open in Overleaf](https://www.overleaf.com/docs?engine=\&snip_name=\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%0A%5CLaTeX%0A%0A%5Cend%7Bdocument%7D)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/in-depth-articles/46-testing-display-and-link-template.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
