3 ms·
LaTeX in my experience, is worse than markdown for one crucial use case: formatting code. Formatting large blocks of monospaced text (especially monospaced text
by quanticle 9y ago
LaTeX in my experience, is worse than markdown for one crucial use case: formatting code. Formatting large blocks of monospaced text (especially monospaced text that includes character sequences that can be interpreted as LaTeX commands) has always been kind of a chore. In markdown, on the other hand, it's as simple as enclosing the text between two sets of triple-backticks (```).
- tincholio 9y ago\usepackage{listings} \begin{lstlisting} your code here \end{lstlisting} That's not much harder, is it? Plus, it has a ton of other functionalities you might want.
- marten-de-vries 9y agoNow add syntax highlighting. In Markdown, it's trivial (```language-name), in LaTeX, you're going to have to define a style. LaTeX is more flexible, but it does come at a cost.
- tincholio 9y agoMaybe you should take a look here and disabuse yourself of that idea: https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings Relevant bit: It supports the following programming languages: ABAP2,4, ACSL, Ada4, Algol4, Ant, Assembler2,4, Awk4, bash, Basic2,4, C#5, C++4, C4, Caml4, Clean, Cobol4, Comal, csh, Delphi, Eiffel, Elan, erlang, Euphoria, Fortran4, GCL, Gnuplot, Haskell, HTML, IDL4, inform, Java4, JVMIS, ksh, Lisp4, Logo, Lua2, make4, Mathematica1,4, Matlab, Mercury, MetaPost, Miranda, Mizar, ML, Modelica3, Modula-2, MuPAD, NASTRAN, Oberon-2, Objective C5 , OCL4, Octave, Oz, Pascal4, Perl, PHP, PL/I, Plasm, POV, Prolog, Promela, Python, R, Reduce, Rexx, RSL, Ruby, S4, SAS, Scilab, sh, SHELXL, Simula4, SQL, tcl4, TeX4, VBScript, Verilog, VHDL4, VRML4, XML, XSLT. For some of them, several dialects are supported. For more information, refer to the documentation that comes with the package, it should be within your distribution under the name listings-*.dvi. Notes 1 It supports Mathematica code only if you are typing in plain text format. You can't include *.NB files \lstinputlisting{...} as you could with any other programming language, but Mathematica can export in a pretty-formatted LaTeX source. 2 Specification of the dialect is mandatory for these languages (e.g. language={[x86masm]Assembler}). 3 Modelica is supported via the dtsyntax package available here. 4 For these languages, multiple dialects are supported. C, for example, has ANSI, Handel, Objective and Sharp. See p. 12 of the listings manual for an overview. 5 Defined as a dialect of another language If you want to get fancier, and have pygments in your system, you can use the minted package, instead.
- marten-de-vries 9y agoAh, seems like the situation is better than I remembered. I confused colored syntax highlighting with the default settings, which highlight using font weight/italicness etc. I did try minted once, but never used it in practice. The dependency on pygments making the documents more system dependent is less than ideal.
- tincholio 9y agoYou can of course redefine the default style if you don't like it, but that is no more work than doing the equivalent in CSS (I guesS?) for whatever MD renderer one uses. I agree that pygments adds a bunch of dependencies, which may be too much just to get some colored syntax highlighting.
- kuschku 9y agoIf you can type ``` without breaking your hand. ` is a three-key combination AND a dead key on non-US keyboards.
- jnxuw 9y agoThat's very easy by using the minted package, and even in Debian, it is installed by default: \begin{minted}{python} def square(x): return x * x \end{minted} Does not look difficult to me.