News for hackers. Stuff that matters.
Re:Nota is a language for writing documents, like academic p... by dash2 on Friday October 20, 2023 @02:27AM (#37952951)
Can I make a simple point?

As an academic, 99% of my time is spent doing two things:

1. Writing statistical computations using a language like R or python.

2. Writing English text.

The most important thing about a document language is that it should prioritize those things. For example, here's why Rmarkdown/Quarto is better than TeX. A TeX document starts:

    \documentclass[12pt,a4paper]{article}
    \usepackage{amsmath}
    \usepackage{amsthm}
    \usepackage{geometry}
    \usepackage{enumitem}
    \setitemize{noitemsep}
    \usepackage{tabularx}
    \usepackage{setspace}
    \newcolumntype{x}{>{\centering\arraybackslash}X}

    \newtheorem{theo}{Theorem}
    \newtheorem{prop}[theo]{Proposition}
    \newtheorem{lemma}{Lemma}

    \usepackage{fontspec,xunicode}
    \defaultfontfeatures{Mapping=tex-text}
    \setsansfont{TeX Gyre Heros}
A quarto document starts:

    ---
    title: "Natural selection in the Health and Retirement Study"
    author: "XXX"
    abstract: |
      I investigate natural selection on polygenic scores
      in the contemporary US, using the Health and Retirement       
      Study. Results
      partially support the economic theory of fertility as
      an explanation for natural selection: among both white 
      and black respondents,
      scores which correlate negatively (positively) with education are
      selected for (against). Selection coefficients are
      larger among low-income
      and unmarried parents, but not among younger parents or those with less 
      education. I also estimate effect sizes corrected for noise in the 
      polygenic scores. 
    date: "September 2023"
You see the difference in emphasis.
Re:Nota is a language for writing documents, like academic p... by nanna on Friday October 20, 2023 @02:45AM (#37953052)
I don't get the problem. If 99% of your documents need the same packages and formatting, then all you need to do in LaTeX is create a template (eg via Yasnippet in Emacs) or dump it all in a LaTeX class file and then import it in your frontmatter, and Bob's your uncle. There are many frustrating things about LaTeX but I don't see how this is one of them.
Re:Nota is a language for writing documents, like academic p... by dash2 on Friday October 20, 2023 @02:58AM (#37953133)
Probably that's true. But first, I don't know how to create a class file, or a template (if that is a LaTeX thing). And since I've never seen anyone else do this, I guess that most academics don't either.

Second, my point isn't just about the specific issue, it's that this issue reveals how TeX thinks about the world. It thinks you want to spend your time writing TeX. No, I want to spend my time writing English. Here's another example. This is how you embed an image in quarto - it's just markdown:

    ![Caption](path/to/image.png)
And here is how you do it in TeX:

    \begin{figure}[t]
    \includegraphics{path/to/image}
    \centering
    \end{figure}
Which of these is easier to memorize and to read past? Similar comments apply to tables, links, numbering and so on.
Re:Nota is a language for writing documents, like academic p... by mr_mitm on Friday October 20, 2023 @03:36AM (#37953332)
I understand your frustration. Maybe it helps to know where this problem comes from.

TeX is extremely powerful and lets you create arbitrary documents. This is the first time I heard of quarto, but apparently it makes a lot of choices for you that you understandably don't really care about.

Instead of developing quarto, one could have simply written a LaTeX class that defines a function like so:

    \newcommand{\image}[2]{\begin{figure}[t]\includegraphics{#2}\caption{#1}\label{#2}\centering\end{figure}}
Now you can just write:

    \image{caption}{path/to/image}
Of course, it is now much less flexible, as you cannot define a custom label or different placement instructions. But that is the price you pay for short and memorable syntax.

By the way, developing a LaTeX class is not hard. It is more or less a file whose name ends in `.cls` with all the commands that you typically put in your preamble. It just needs a header of three lines that define some meta data and also supports options. See here for an example: https://github.com/latex-ninja/colour-theme-changing-class-t...

You put it in the same directory as your main tex file or in the system wide TEXMFHOME or user-specific TEXMHFHOME.

Re:Nota is a language for writing documents, like academic p... by xeyownt on Friday October 20, 2023 @04:21AM (#37953561)
Yes, and with tools like ChatGPT it's even easier to write TeX documents.

I exposed this very problem and ChatGPT proposed exactly the same solution, and also another one using a custom environment.

Re:Nota is a language for writing documents, like academic p... by gbalduzzi on Friday October 20, 2023 @07:04AM (#37954579)
That is just an expression of the LaTex problem though.

People (as in, the majority of people) will not be comfortable using a tool that is so unintuitive and hard to use that you need to use an AI to help you in writing.

Writing a document is not supposed to be hard and require assistance to do.

Re:Nota is a language for writing documents, like academic p... by jacobolus on Friday October 20, 2023 @03:01PM (#37960095)
The problem is that your goals and skills don't match the purpose and capabilities of the tool, not that the tool is insufficiently "intuitive".

Manuscript composition used to be: write your document by hand or with a typewriter, handwrite some notes in the margin, throw in some pages with your figures on them, then let a professional typesetter take care of all of the technical details of making a typeset document for printed output. This was a whole separate career, and the typesetter would sink almost as much time into making your document look pretty as you put into writing it.

If you are using LaTeX, you are taking on the role of the professional typesetter yourself, and you need to make some specific technical choices to get some output from it. This can be a problem if you are inexperienced and don't know which choices to make or in a hurry and don't want to make any choices, but is also good insofar as it lets you actually produce a professional quality document if you have the time and expertise to do so. The difficulty involved is at least an order of magnitude less than doing composition of metal type.

If you are using markdown (or whatever), you are just punting on having a professional document at the end, and/or letting a system make all of the choices for you (often badly), or perhaps expecting to still hand off your document to a professional at the end for proper typesetting.

Re:Nota is a language for writing documents, like academic p... by dash2 on Friday October 20, 2023 @04:56PM (#37961405)
> with tools like ChatGPT it's even easier to write TeX documents.

I am not quite sure whether this is satire?

Re:Nota is a language for writing documents, like academic p... by eviks on Friday October 20, 2023 @04:48AM (#37953729)
> Instead of developing quarto, one could have simply written a LaTeX class that defines a function like so:

If it's so simple, why isn't there QuarTeX that does all of that and removes the extreme verbosity barrier?

Re:Nota is a language for writing documents, like academic p... by mr_mitm on Friday October 20, 2023 @05:39AM (#37954050)
Because doing something like this is opinionated. The LaTeX developers try to do the opposite: they want to provide packages that cover as many usecases as possible.

And users of LaTeX are probably not knowledgeable enough or too busy to publish their opinionated subset of LaTeX as a class. I don't know for sure. There is no central body that has an interest in removing barriers, so you might as well ask me or yourself why I or you haven't published anything.

I developed something similar to this at my company, because we write lots of LaTeX documents and need shortcuts like this not only for brevity but also so that we achieve some consistency across the entire team. It's only for internal use though and thus not public.

Re:Nota is a language for writing documents, like academic p... by eviks on Friday October 20, 2023 @06:18AM (#37954307)
> they want to provide packages that cover as many usecases as possible.

How would this macro exclude the coverage of other use cases? The language primitives would still be there to do the original code

> There is no central body

That's true for plenty of other syntaxes that at the same time aren't like this

Re:Nota is a language for writing documents, like academic p... by mr_mitm on Friday October 20, 2023 @06:44AM (#37954459)
As I said: Maybe you want to specify a different placement option like `b` instead of `t`. Maybe you don't want the label equal to the file path, in particular if you happen to include an image twice.

Or you don't want it centered. Or you want several images in one figure environment arranged in some way. Or you want to scale the included image to fit only 70% of the page width. Or maybe you want to rotate the included image by 90 degrees. Many more use cases are imaginable.

You could define the macro to cover all of this, but then you might as well just write the original code.

Re:Nota is a language for writing documents, like academic p... by eviks on Friday October 20, 2023 @07:26AM (#37954731)
And as I replied: how does any of this *prevent* you from "cover[ing] as many usecases as possible" given that writing the original code is always an option?
Re:Nota is a language for writing documents, like academic p... by smaudet on Saturday October 21, 2023 @01:29AM (#37964336)
Namespaces and constraints.

The first (namespaces) contrast speed (brevity) and specificity (verbosity). Namespacing (long names) are great when you don't have a good idea the full scope - putting your library in namespace means you generally never have to be concerned that terms will overlap.

Macros tend to be the opposite - short, in global namespace, with little flexibility. They constrain the possible output by focusing on a certain goal - this is the point of the macro usually, to avoid some common pitfall without being overly verbose.

If you combine the two, you have a problem - either the macro dictates your preference, or many different macros must exist which, usually being brief or in pursuit of similar goals, will result in namespace collisions.

So of course you can define them, but generally this is better suited towards a specific use case or organization.

Or at least that's the idea. I'm not sure some standard approachable macros are a bad thing, as long as you can redefine them later or pick and choose, but I do get the point of "why not", because they don't want to constrain the language itself. The irony is other systems do this for them and tex becomes more an outsider thing and systems like markdown are far more constrained...

On the other hand there is no way to make everyone happy, and I respect the Tex author decision to opt for a less-is-more strategy wrt to offering building blocks only not templates.

You are of course free to build your template library, and make it popular, but be forewarned that likely whatever it is popular at doing (say, writing science articles), will affect what TeX is used primarily for. Which is the "why".

Re:Nota is a language for writing documents, like academic p... by nanna on Friday October 20, 2023 @05:37AM (#37954031)
More on creating your own class file:

https://www.overleaf.com/learn/latex/Writing_your_own_packag...

How I do it...

I keep a directory called LaTeX inside my home directory. Inside that I keep a file with all my frontmatter, myfrontmatter.sty (technically a package rather than a class), and also my biblatex file and a scan of my signature for signing letters. When I start a new LaTeX document and add the line \usepackage{/home/nanna/LaTeX/myfrontmatter} to the top (note, no .sty). This keeps my frontmatter minimal and tidy.

Inside myfrontmatter.sty:

  \NeedsTeXFormat{LaTeX2e} 
  \ProvidesPackage{/home/nanna/LaTeX/myfrontmatter}[2015/01/01 by me]

  \RequirePackage{amsmath} % Just replace `usepackage` with `RequirePackage`
  \RequirePackage{amsthm}
  ...

  \addbibresource{/home/nanna/LaTeX/biblatex.bib}
  ...

  %% Macros like for inserting my signature
  \newcommand{\mysignature}{\noindent\includegraphics{/home/nanna/LaTeX/signature.png}}
  ...
  \endinput % Not sure if this line does anything?
And that's it. I never have to worry about a package I've forgotten to add in. Granted a journal might not accept my custom package but I can always just copy and paste it all into my frontmatter, minus the top two lines and replace all the RequirePackages with usepackages.
Re:Nota is a language for writing documents, like academic p... by dash2 on Friday October 20, 2023 @04:54PM (#37961384)
Thanks for the help and I can feel the enthusiasm. I have to tell you, my hatred for TeX is profound and goes far beyond this one point. But if I start ranting, I'll never stop.
Re:Nota is a language for writing documents, like academic p... by smaudet on Saturday October 21, 2023 @12:57AM (#37964210)
Didn't you say with quarto you had to debug a 5 layer pipeline? I wonder if it's not biasing you here a bit...(stuck fighting "arcane" latex syntax somewhere at 3 in the morning).

I'm not saying you should love TeX, but it's a bit like saying you hate assembly language - if you have the wrong abstractions (writing a 3D game or a web page using assembly language) of course the experience will be beyond frustrating. I don't hate assembly language, but I generally don't need to touch it because higher order abstractions generally suffice. If I am optimizing my compiler output, though, then it's a tool I can use.

Ofc if I have the wrong or missing tools while using assembly language, or any other TBH (python, html, etc), that is also a source of considerable frustration. Not sure where the "hatred" comes from, but perhaps you encountered a poorly done package or editor?

Re:Nota is a language for writing documents, like academic p... by dash2 on Saturday October 21, 2023 @04:43AM (#37965145)
Re:Nota is a language for writing documents, like academic p... by smaudet on Wednesday October 25, 2023 @02:37PM (#38016533)
To surmise from your article:

* "It gets in the way. If I open my article in a text editor, I want to see the title, author, abstract and first paragraph." * You feel forced to use it. " One idiot reviewer told me, as a supposedly legitimate critique of my work: “this wasn’t written in TeX”. PhD students are forced to learn it"

Some of your points about escape codes etc. seem contrived, and the alternatives are just more buttons hidden in menus or a bunch of search. I'm not defending \’e but TBH that seems pretty darn logical compared to e.g. hitting a keycombo and searching through a million characters in a unicode table.

The first is a matter of a good editor, the second is true of any system you can be asked to use. I've been forced to use some pretty miserable programs in the past, so I can commiserate.

Hmm. As a PhD student you feel constrained to do something in a way you don't want to. I don't think that's a good enough reason to say something sucks, though. Why do PhD students use it? I'm not one, but I can suspect an answer - print journals. You can/could submit a TeX article and have it relatively seamlessly typeset into a for-print journal.

I don't work with print - I imagine if I did I might seriously consider TeX, and if parts of it legitimately sucked, seek to replace or modify those. Markdown is good enough for the majority of what I need to do. Microsoft Word is my "useless disease program" that all good "computer workers" are forced into using, and they become proud they know how to use templates and bullet formats. For what I typically use documents for, I would tell someone to use TeX before I told them to use Word, a quirky mess of program filled with bugs from a toxic work culture (and I don't need TeX so I don't use it).

:)

Re:Nota is a language for writing documents, like academic p... by cycomanic on Friday October 20, 2023 @04:58AM (#37953806)
I can tell you as another academic i almost always get links and images wrong in Markdown (which of title URL is in square which in round brackets, forgetting the !, the conventions around file paths (some Markdown processors need file://...). Admittedly if I would write always one Markdown style I would get used to it, on the other hand I never get it wrong in latex and let's not even talk about how to do different alignment, captions and labels.
Re:Nota is a language for writing documents, like academic p... by seanhunter on Friday October 20, 2023 @06:57AM (#37954536)
That’s a great of the tradeoff. On the surface the latex version looks harder, but you can specify a caption, how the figure floats with other items, how it’s justified, the zoom level, you can add a reference label that you can hyperlink to from elsewhere in the doc, etc etc etc.

The markdown one you get what you get. Maybe that’s fine. If it isn’t you are out of luck.

The latex one requires more of you but gives you much more functionality in return.

Which is better is going to be entirely situational/personal preference.

Re:Nota is a language for writing documents, like academic p... by enriquto on Friday October 20, 2023 @08:28AM (#37955175)
> in quarto - it's just markdown:

    >    ![Caption](path/to/image.png)
> And here is how you do it in TeX:

    >    \begin{figure}[t]
    >    \includegraphics{path/to/image}
    >    \centering
    >    \end{figure}
This is not the same thing! The LaTeX equivalent to your markdown would be

     \includegraphics{path/to/image.png}
which is arguably simpler and cleaner than the markdown. The figure environment is unnecessary when you just want to put a figure right there. You only need the figure environment when you want your image to "float" to a random place in your page.
Re:Nota is a language for writing documents, like academic p... by professoretc on Friday October 20, 2023 @09:30AM (#37955715)
> You only need the figure environment when you want your image to "float" to a random place in your page.

Which is also something the Markdown version can't do at all (give fine control over how the image is positioned). You have to use raw HTML plus probably some CSS if you want that.

Re:Nota is a language for writing documents, like academic p... by dash2 on Monday October 23, 2023 @09:51AM (#37985632)
God, the amount of pain I've had trying to use that "fine-grained control".
Re:Nota is a language for writing documents, like academic p... by ska on Friday October 20, 2023 @01:12PM (#37958787)
Again, apples and oranges. Yes it's more markup than e.g. markdown (which is fundamentally less capable) But how do you do the equivalent ot the [t] and \centering in the former on a per figure bases? what about scaling it differently from other figures in your doc, or embedding a reference in caption with a particular style?

For that matter your equivalent is still one line, it's just \includegraphics{path}. The figure environment is just adding extra capabilities.

I agree not everyone needs to do this, but the trade offs you are illustrating are not "X is better than Y" so much as "X is simpler than Y, and can't do as many things"

For you that trade-off makes sense, great. But I wouldn't generalized it to the value of the tool. I know plenty of academics who are quite proficient at Tex, let alone the simpler Latex, and find it lets them generate the content they want easily enough, given it's power.

This isn't just mathematicians either, though most of the people I know using it came to that out of a need to do math typesetting properly. How would you for example generate a mixed language document with both left-to-right and right-to-left languages formatted correctly?

LaTeX's real problem isn't the syntactic load (easily handled with a decent editor) it's the package system. It can be abused to e.g. generate conference posters well, but it's hairy once you get into the details.

Re:Nota is a language for writing documents, like academic p... by PeterisP on Saturday October 21, 2023 @09:02AM (#37966492)
> I don't know how to create a class file, or a template (if that is a LaTeX thing). And since I've never seen anyone else do this, I guess that most academics don't either.

Exactly, academics usually don't do that - they write the text with appropriate markup, and then put it in the publisher's template and the formatting according to the appropriate standards is done. You can write your own template, but usually you use someone else's, with the big benefit that you can generally move your content to a very different template of a different publisher with minimal or no changes to your actual writing.

Now how would I do that in quarto - what (and how much) would I need to write to ensure that, for example, the captions for all the images and all the references to the images are all formatted in a specific manner? Because for quarto I would need to make my own template specifying the exact formatting and layout, and a quick browse of its documentation didn't lead me to any examples on how I would control that.

In sane environments there is a split between text and formatting, however, the formatting part has to be sufficiently powerful to meet the various requirements, so there is a certain quite high minimum bar to meet there. Latex works because I can rely that I will be able to easily get my markup laid out exactly as required by arbitrary standards, for any markdown-type standards I need some assurance that this will be possible and easy, that I won't need to (for example) go over all my references and do something to them.

Re:Nota is a language for writing documents, like academic p... by systemEarth on Friday October 20, 2023 @04:17AM (#37953542)
You might be interested in typst. It offers an incremental live compiler.
Re:Nota is a language for writing documents, like academic p... by dmulligan on Friday October 20, 2023 @04:43AM (#37953694)

   \documentclass{article}

   \title{Natural selection in the Health and Retirement Study}
   \author{XXX}
   \date{September 2023}

   \begin{document}

   \maketitle

   \begin{abstract}
   I investigate natural selection on polygenic scores in the contemporary US, using the Health and Retirement Study.
   Results partially support the economic theory of fertility as an explanation for natural selection: among both white and black respondents, scores which correlate negatively (positively) with education are selected for (against).
   Selection coefficients are larger among low-income and unmarried parents, but not among younger parents or those with less education.
   I also estimate effect sizes corrected for noise in the polygenic scores. 
   \end{abstract}

   \end{document}
Re:Nota is a language for writing documents, like academic p... by bionhoward on Friday October 20, 2023 @05:58AM (#37954178)
Makes me wonder if Nota did work with Rust, then we could move the dependencies into a cargo.toml file and compile our documents. That would enable declarative macros for document generation at compile time as well as interactive rust code inside your document at reading time. Plus you could refer to the dependencies by their package name like amsmath::line or something
Re:Nota is a language for writing documents, like academic p... by seanhunter on Friday October 20, 2023 @06:49AM (#37954484)
The difference is you know the easy way to get what you want in rmarkdown/quarto but only know the hard way in latex?

My latex docs look nothing like that because I put all the boiler plate in a .sty file.

Re:Nota is a language for writing documents, like academic p... by ska on Friday October 20, 2023 @12:58PM (#37958603)
You are comparing apples and oranges, at least a bit. The latex equivalent is

  \documentclass{article}
  \title{Natural selection in the Health and Retirement Study}
  \author{XXX}
  \date{\today}
  \begin{document}
  
  \begin{abstract}
      I investigate natural selection on polygenic scores
      in the contemporary US, using the Health and Retirement       
      Study. Results
      partially support the economic theory of fertility as
      an explanation for natural selection: among both white 
      and black respondents,
      scores which correlate negatively (positively) with education are
      selected for (against). Selection coefficients are
      larger among low-income
      and unmarried parents, but not among younger parents or those with less 
      education. I also estimate effect sizes corrected for noise in the 
      polygenic scores.
  \end{abstract}
  ...
  \end{document}


Everything else you have there in your preamble is about either adding capabilities or changing formatting, you don't show how that is achieved in the other markdown.

I think I get your point, but in practice that part doesn't really get in the way, and if you are doing the same thing over and over (e.g. for the same publication) it's just a template anyway.

I don't love Tex/Latex, but most of the other markdown comparisons that emphasize "it's simpler" are because they can't do as much. Which is fine until you need some of that capability.

Re:Nota is a language for writing documents, like academic p... by dash2 on Friday October 20, 2023 @04:53PM (#37961367)
It's absolutely true that you may need to customize things. And then you are stuck with the big quarto disadvantage: debugging a toolchain that typically looks like

    quarto -> knitr -> markdown -> pandoc -> [tex -> pdf | html]
and not knowing exactly where the error came from.

At the same time, the markdown defaults produce a nice, readable paper. The TeX defaults get you something that reminds you of Rubik's Cube and Duran Duran.

Re:Nota is a language for writing documents, like academic p... by smaudet on Saturday October 21, 2023 @12:44AM (#37964160)
Is Lyx still around? I remember it had good defaults. Haven't used in ages and it had some installer issues but I got fairly comfortable writing latex papers without learning a ton of latex...

Ofc that was a major downside, something other markdown editors figured out - if you give people buttons that make it easy and you make it easy to learn, they will learn what they need.