1

I want to copy some good answers to my local tex editor in order to review sometimes future. There will be many errors since like ** ** means bold, space x 4 means writing codes, etc. And sometimes I want to write some answers in local tex editor, and after compile successfully then directly copy to tex.stackexchange.

I want to write following templates :

\documentclass{article}
%some packages or newcommand I need to import    


\begin{document}
%I can directly copy some answers in tex.stackexchange
\end{document}  

What environment(packages, newcommand,etc.) does tex.stachexchange uses? Or how to write an environment(preamble) in LaTeX such that it will be compatible from the syntax in tex.stackexchange?

  • 5
    TeX.SE doesn't use LaTeX for formatting, it uses Markdown syntax. – CarLaTeX Mar 2 '19 at 20:00
  • 4
    The contents here are not rendered in LaTeX. Posts are written in some kind of markdown/HTML flavour. (There are some ways to render markdown with TeX, e.g. ctan.org/pkg/markdown or Pandoc. But TeX itself does not really do that out of the box.) – moewe Mar 2 '19 at 20:00
  • See also here: tex.stackexchange.com/questions/101717/… – CarLaTeX Mar 2 '19 at 20:02
  • @CarLaTeX Or how to write an environment in LaTeX such that it will be compatible from the syntax in tex.stackexchange? – maplemaple Mar 2 '19 at 20:02
  • 1
    Ok I see, I misunderstood - but why would you want to save the full answer in LaTeX? – Marijn Mar 2 '19 at 20:19
1

If we look at the mwe you provided (pasted) in its native state we can see it is part of a web page and would need some serious decoding to restore it as you intended it to look.

<pre class="lang-tex prettyprint prettyprinted"><code><span class="kwd">\documentclass</span><span class="pun">{</span><span class="pln">article</span><span class="pun">}</span><span class="pln">
</span><span class="com">%some packages or newcommand I need to import    </span><span class="pln">


</span><span class="kwd">\begin</span><span class="pun">{</span><span class="pln">document</span><span class="pun">}</span><span class="pln">
</span><span class="com">%I can directly copy some answers in tex.stackexchange</span><span class="pln">
</span><span class="kwd">\end</span><span class="pun">{</span><span class="pln">document</span><span class="pun">}</span><span class="pln">  </span></code></pre>

However if we simply cut and paste as plain text to ANY editor from simple notepad to the most complex of systems then it will be compatible, compliable and compilable

\documentclass{article}
%some packages or newcommand I need to import
\begin{document}
%I can directly copy some answers in tex.stackexchange
Hello maplemaple
\end{document}

\pretend this is latex {class}
It may not be immediately apparent that in most browsers if you
double click the start or end of a structured code block like this  
it will be possible to copy to clipboard, try me at start \ or here >

So there is generally no need to alter / decode answers for use in your editor other than any related comments to a correct answer, assuming you know it is correct :-)

For wider discussions on how's and why's you could look at Feature request: Better support for copying code from question or answers and the related links at the side of that discussion.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.