Template talk:LaTeX/Example
Problem with multi-line examples appear to be solved
Until recently the Example template rendered multi-line examples poorly. Line breaks in the source would not show up in the rendered example, making them hard to read. For example, the LaTeX code
\documentclass{article}
\begin{document}
%\input{Section_1}
%\input{Section_2}
%\input{Section_3}
\input{Section_4}
%\input{Section_5}
\end{document}
would be rendered as
\documentclass{article} \begin{document} %\input{Section_1} %\input{Section_2} %\input{Section_3} \input{Section_4} %\input{Section_5} \end{document}
Note how the meaning of the sample becomes different because newlines have meaning in the syntax of LaTeX. In the badly rendered version of the sample everything after the first '%' is just comment, effectively leaving only
\documentclass{article} \begin{document}
, which has a different meaning from the original example.
The change () shows that the solution lay in removing the enclose=none command. This sounds rather obscure. Some heavy-duty digging in the Wikimedia documentation gives us the mw:Extension:SyntaxHighlight page, which tells us:
- The
inline
attribute indicates that the source code should be inline as part of a paragraph (as opposed to being its own block). ... For backwards-compatibility, anenclose="none"
attribute results in the same behaviour.
This reveals that enclose="none"
has the same meaning as inline
, and explains what it does.
I wholeheartedly approve of this change to the template and thank User:Johannes Bo for making it.
--Hops Splurt (discuss • contribs) 12:13, 12 August 2015 (UTC)
- User:Hops Splurt All the effort in investigating goes to User:ChrisHodgesUK, i just followed his lead. All thanks should be directed to him :-). Please see https://en.wikibooks.org/wiki/Template_talk:LaTeX/Usage --Johannes Bo (discuss • contribs)
- Ah, that was the page that I couldn't find again while looking for the discussion page about broken examples. So there is Template:LaTeX/Example and Template:LaTeX/Usage. I'll try to add a note and a link in the documentation of both to make editors aware of the other template. Ideally there would only be one template (only LaTeX/Example) which creates the "Usage" form if the
render=
parameter is omitted. --Hops Splurt (discuss • contribs) 18:53, 12 August 2015 (UTC)
- Ah, that was the page that I couldn't find again while looking for the discussion page about broken examples. So there is Template:LaTeX/Example and Template:LaTeX/Usage. I'll try to add a note and a link in the documentation of both to make editors aware of the other template. Ideally there would only be one template (only LaTeX/Example) which creates the "Usage" form if the