[HN Gopher] Typst: An easy to learn alternative for LaTex
___________________________________________________________________
Typst: An easy to learn alternative for LaTex
Author : vogu66
Score : 572 points
Date : 2024-07-20 08:14 UTC (1 days ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| sprinkly-dust wrote:
| Having composed many pieces of coursework using Typst, I must say
| that it certainly makes academic writing more streamlined,
| engaging, and dare I say fun -- though that might just be me. The
| functional nature of Typst's syntax ensures I don't have the
| erratic behaviour emblematic of modern day Microsoft Word and
| sometimes even Google Docs. Using a local IDE such as VSCode
| brings all the features one could like.
|
| In comparison to LaTeX, overall document typesetting is far more
| straightforward. However, for long multi-page stretches of
| equations solving, I feel that LaTeX is easier to type than Typst
| because its syntax is not that of a functional programming
| language but more akin to markdown. Thus, one does not need to
| think as far in advance when typesetting equations with lots of
| functions, superscript, and subscript.
| crngefest wrote:
| As someone who almost never needs equations, does this have any
| benefits to me over using markdown?
| ksynwa wrote:
| It depends on what you are doing with your markdown files.
| For example, if you are using them as the source for a
| statically generated website typst won't do much for you.
| PartiallyTyped wrote:
| You have more control over the style and structure. If you
| use markdown + css, that's a different story.
| crngefest wrote:
| Yea that is my setup right now.
|
| I write markdown and use eleventy + nunjucks templates to
| build the final result.
|
| It's pretty easy to create new layouts and styles for
| really any use case with that setup in minutes.
| PartiallyTyped wrote:
| If that's the case, I don't think you will get any
| benefits by switching to Typst.
| WolfOliver wrote:
| With or without equations, just use MonsterWriter. It gives
| you LaTeX results without needing to know what LaTeX is.
|
| But, yes LaTeX has other benefits, e.g. citing references, or
| creating PDFs according to layout and typesettings best
| practices.
| m_kos wrote:
| MonsterWriter is your product, correct?
| adwn wrote:
| It is customary to add a short disclaimer when you're
| promoting your own product or project.
| WolfOliver wrote:
| Yes it is my own product. Sorry for not pointing it out.
| beezlebroxxxxxx wrote:
| I would say probably not.
|
| Markdown is really more about getting words down in plain
| text with a very simple structure for rendering on the web.
|
| Typst and LaTex make stark distinctions between composing and
| typesetting. They are programmatic typesetting systems with
| very structured and fine grained control over the look and
| design of a document once it's compiled and rendered as a
| PDF.
|
| If all you're doing is writing prose then I honestly think
| typesetting programs are overkill _unless_ you do want very
| fine grained control over how your documents look.
| Winsaucerer wrote:
| You've had some good replies already, but just want to add my
| thoughts. Markdown to me is more about (a) the content (the
| actual words) and (b) the semantics (text emphasis, headings,
| etc, which communicate information about the importance or
| meaning of particular things).
|
| Typesetting systems like Typst or LaTeX go beyond this.
| They're also about presentation, how precisely it is laid
| out, on mediums such as print or PDF. Is that something you
| need? If you care more about the content and its meaning, and
| are happy to have it rendered differently in different
| situations (a preview in Visual Studio Code, or passed
| through a markdown-to-html renderer, or viewed in Obsidian,
| etc), then Markdown might not just be fine, it may be
| preferable. But if you need to do things like print this on
| paper for mailing, email in a PDF, that sort of thing, then
| you'll want something more.
| thangalin wrote:
| A few Markdown documents I've converted to PDFs:
|
| * https://impacts.to/downloads/lowres/impacts.pdf
|
| * https://whitemagicsoftware.com/softcover/technical.pdf
|
| * https://whitemagicsoftware.com/softcover/jekyll-hyde.pdf
|
| Respectfully, keeping presentation logic and content
| completely separated while having precise control over
| layout can happen with Markdown, as the example documents
| demonstrate. The ConTeXt typesetting system makes keeping
| such separation possible.
|
| The deeper issue relates to the software's architecture,
| which, IMO, systems like Typst, Obsidian, and others fail
| to generalize broadly enough. Here's KeenWrite's
| architecture (the "Proposed" row):
|
| https://gitlab.com/DaveJarvis/KeenWrite/-/raw/main/docs/ima
| g...
|
| Although only Markdown is currently implemented, it's
| possible to plug other text-based input formats to produce
| an XHTML document. The instructions for how to typeset
| XHTML documents are defined by a theme. You can think of a
| theme as an XML to TeX translation layer. From there, going
| from XML to TeX is straightforward (when using ConTeXt, at
| least), allowing full control over the final output format
| (be it PDF, ePub, and so forth).
|
| I am the author of KeenWrite. The following tutorial shows
| how its themes work:
|
| https://www.youtube.com/watch?v=3QpX70O5S30&list=PLB-
| WIt1cZY...
| constantcrying wrote:
| >A few Markdown documents I've converted to PDFs:
|
| These aren't Markdowns converted to PDFs. These are HTML
| websites rendered as PDF, where at some early point some
| text with basic formatting was fed in.
|
| >keeping presentation logic and content completely
| separated while having precise control over layout
|
| Does anyone really want that? I certainly wouldn't want
| that separation. I want to create some document and not a
| sophisticated template, so I am always willing to
| sacrifice generality over momentary needs, if I can't
| force the layout, then I need to waste time to implement
| some generality, which I don't need. Completely the wrong
| approach to document creation.
|
| This looks like you really want to have a web framework,
| not a document creation system.
| thangalin wrote:
| > These aren't Markdowns converted to PDFs
|
| Would you like to see the source Markdown documents? My
| workflow is: Markdown -> XML (XHTML) ->
| TeX -> PDF
|
| If that isn't converting Markdown into PDF, what would
| you call it?
|
| > Does anyone really want that?
|
| At time of writing KeenWrite has had over 4,000
| downloads. So, maybe? However, my point wasn't whether
| people want it (besides me). My point was that it is
| technically possible to keep a Markdown document's
| content separated from its final presentation form (e.g.,
| PDF).
|
| > This looks like you really want to have a web
| framework, not a document creation system.
|
| Not really: I want to write in Markdown (or R Markdown)
| using interpolated variables and generate PDF documents.
| I have spent about 9 years working on a cross-platform
| desktop text editor that allows me to do so.
| constantcrying wrote:
| >Would you like to see the source Markdown documents?
|
| I am pretty sure I know what they look like from the end
| result.
|
| My point was that almost all of the design effort wasn't
| contained in the markdown. So clearly there were at least
| two major inputs to the documents. But of course you
| agree with that.
|
| >Not particularly; I want to write in Markdown (or R
| Markdown) using interpolated variables and generate PDF
| documents.
|
| To me the total separation only makes sense if you are
| designing for unknown content. If you control the input
| of content and formatting, then a closer linkage between
| both seems superior. Markdown is (intentionally)
| extremely limited, so everything that markdown can't do
| needs to be implemented in a general way on the
| formatting layer. Obviously that is more tedious if you
| have total separation.
|
| What I meant by "web framework" is that they can't assume
| content, so need to deal with generality. Essentially
| what you are writing is a website generator, except with
| PDF being the end output. But generating general and
| reusable components doesn't seem to be how I would want
| to create a document.
| constantcrying wrote:
| Typst deals with documents, so if you want to prepare an
| actual document, with a defined page layout, style, font,
| etc. typst gives you that.
|
| Markdown does not do any of that, it just gives you html.
|
| You would want to use typst if you want to create a document
| and need to control how that document looks from the language
| itself. Even if you were to render the markdown html to a
| PDF, markdown itself, or even css doesn't give you control
| over many parameters of the output document.
|
| There basically is no competition between the tools, they
| target different output formats.
| aragilar wrote:
| I've done .doc -> .md -> .tex -> .pdf via pandoc (e.g. to
| convert a confluence document to a nicely typeset PDF), so
| I'm not sure there's much difference.
|
| Naturally, a format with more metadata loses metadata when
| converted to one with less (and the reverse, you may need
| to add metadata in when going up the chain), but unless
| your document is bound to a specific format (in which case,
| I'd pick RST for HTML and LaTeX for pdf), markdown gives
| you the content and pandoc lets you specify a template (and
| with pandoc, you can take the markdown and generate slides
| in HTML, PDF and create notes through the different
| outputs).
| constantcrying wrote:
| Conversions don't just loose metadata, you loose the
| ability to specify things. LaTeX shines because it can do
| everything by itself, markdown clearly can't and even
| with a TeX template you loose much of TeX's power.
|
| You should start out by defining your desired output and
| needed input. I realize that 99% of document content can
| be fully realized in markdown, but the 1% can easily be a
| total deal breaker and make using markdown a complete
| nonstarter.
| wlievens wrote:
| Markdown doesn't give you a table of contents, an index,
| page breaks, control over typesetting, control over table
| layout, captioned figures, diagramming tools, etc. The
| difference is about the same magnitude as between Pong
| and Call of Duty. Yes they're both video games, sometimes
| one is preferable over the other, but they are not
| equivalent.
| padthai wrote:
| Pandoc/Quarto markdown gives you most of these.
|
| In my experience, it rarely really matters fine control.
| If the effort is too big to tweak the templates/markdown
| you export it to an intermediate state
| (LaTeX/Office/whatever) and drop the original markdown
| source.
|
| There is no lock-in.
| gumbojuice wrote:
| Having composed pieces of academic writing, I would like that,
| journals would start to supporting typst, or, plugins/bridges
| to LaTeX/Word would fall in place.
|
| For now I would not chose to write a paper in typst, because I
| most certainly need to convert it once it leaves the
| institution (even arXiv require LaTeX source).
|
| Tooling around LaTeX is quite good today, with a plethora of
| IDEs helping. Personally I use Emacs' Org-Mode which compiles
| to LaTeX.
| tapia wrote:
| The only thing I need to start writing more serious documents
| with Typst is an equivalent to latexdiff. But I really think
| (and hope) that this will replace latex in the future. Alone
| the compilation time makes it so much nice to use! Meanwhile
| I am supporting them by having a pro account, which is not
| even so expensive.
| 2cynykyl wrote:
| Arxiv will accept a rendered pdf, no source files required.
| Are any special features unlocked if source files are
| uploaded?
| CJefferson wrote:
| They autoconvert latex to html. Typst can't currently
| produce html output.
| wiktor-k wrote:
| Just for completeness the html export issue is here:
| https://github.com/typst/typst/issues/721
| Onawa wrote:
| Quarto can convert to typst, html, and LaTeX through
| pandoc.
| AnonymousPlanet wrote:
| Typst is missing vital features to produce professional
| looking documents. Latex and Adobe InDesign use paragraph
| based algorithms for line breaks and hyphenation (see
| http://dx.doi.org/10.1002/spe.4380111102 for Latex). That is
| the main reason why papers written in Word look so
| amateurish. Proper support for footnotes seems to be also
| lacking in Typst.
|
| Footnotes might be handled properly in a future version of
| Typst. Regarding paragraph formatting I'm not so optimistic.
| I've read the thesis and papers by one of the Typst authors.
| They either don't seem to be aware of better approaches or
| they simply don't care about aesthetics.
|
| Edit: Another thing that irks me about Typst is that it does
| not seem to be a purely not-for-profit project. It is tightly
| entangled with their commercial offering, whatever that might
| mean for the future of the "free" version.
| laurmaedje wrote:
| I'm not sure what you're referring to because when
| justification is enabled Typst uses almost the same line
| breaking algorithm as TeX. [1]
|
| One problem we had was over-eager hyphenation. We've
| addressed that recently. [2]
|
| [1]: https://github.com/typst/typst/blob/9b001e21121ab7b564
| 5aa36f...
|
| [2]: https://github.com/typst/typst/pull/4584
| AnonymousPlanet wrote:
| That is great news! It wasn't there the last time I
| checked. Maybe I missed it. Thanks for clarifying!
| thomas34298 wrote:
| FWIW there is already partial LaTeX support for Typst via the
| mitex package:
|
| https://github.com/mitex-rs/mitex
| returningfory2 wrote:
| This is interesting! However, I suspect general TeX support
| in Typst is probably impossible unless you re-implement the
| entirety of TeX within Typst somehow. The TeX language has
| some really terrible properties. For example, the
| tokenization rules can be dynamically changed at runtime
| based on the output that has already been produced. E.g. you
| can write a TeX file that says "typeset this paragraph, and
| if the result is an odd number of lines, change the meaning
| of A from letter to open brace". Thus, fully supporting TeX
| within Typst would seem to require making all of the
| internals of Typst available to the TeX runtime.
| aragilar wrote:
| Is that just common constructs, or can I pull in amsmath and
| other similar packages?
| mkl wrote:
| A number of past discussions and related things:
| https://hn.algolia.com/?q=typst
|
| 1 year ago, 146 comments:
| https://news.ycombinator.com/item?id=35250210
|
| 8 months ago, 34 comments:
| https://news.ycombinator.com/item?id=38354422
|
| 2 years ago, 53 comments:
| https://news.ycombinator.com/item?id=34423590
|
| 2 years ago 30 comments:
| https://news.ycombinator.com/item?id=32209794
| PhilippGille wrote:
| And this new post likely triggered by
| https://news.ycombinator.com/item?id=41006565
| pocket_titan wrote:
| I've been finding Typst a great tool for ~90% of my use-cases --
| in the other 10%, I'll still reach for LaTeX for the extra power
| (tikz, pdf images, tagged pdfs (!) (this is becoming more and
| more of a requirement when publishing/submitting academic texts,
| and AFAIK Typst does not support it yet), but that's okay.
| Excited to see where it goes, as LaTeX is very beginner
| unfriendly and I'd love to see the barrier to entry for
| typesetting lowered so my more non-technical friends can share in
| the power of pretty texts & CVs.
| joooscha wrote:
| At least for a tikz equivalent, I found cetz [1] to be very
| useful. I am not sure how it compares feature-wise. But I could
| easily build some graphs with it.
|
| The one thing that really makes me excited when using Typst is
| that I find it very intuitive, meaning the time between not
| knowing how to do a certain thing and me being pleased with the
| result is much shorter with Typst compared to latex.
|
| [1]: https://typst.app/universe/package/cetz/
| Neywiny wrote:
| This feels like a mix of markdown readability with latex control.
| I'm not sure yet that I need that middle ground. Currently I'm
| doing docs in markdown, reports in Python generated tex, coupled
| with hardcoded preambles. That seems fine so far.
| fhd2 wrote:
| Seems like it's not built on top of LaTex, so you presumably
| can't drop into LaTex when Typst can't do what you need, or did I
| just miss that?
|
| LaTex is positively arcane, but I still use it for all my writing
| since it's so incredibly versatile: Academic papers, letters,
| contracts, forms, invoices, tons of packages, pretty easy to
| apply regional standards, ...
|
| How I manage to not go insane is Org Mode: I can write almost
| everything in something similar to Markdown but do inline LaTex
| as needed (since it compiles from Org to Latex to PDF). I find
| that incredibly powerful.
| mr_mitm wrote:
| True, it can't fall back to LaTeX. It's not there yet, but give
| them some time and there won't be any cases that Typst can't do
| that LaTeX can. It's already impressively close if you ask me.
| arnsholt wrote:
| The genius of TeX is that it's a programming language for
| document production, that can mostly look like markup. The
| further genius(?) is that the language works in such a way that
| you can do more or less arbitrarily complex things, while still
| exposing an interface to the user that feels like markup. This
| makes for a language that is sometimes, honestly, completely
| bananas. But when wielded correctly, it's great.
| SkiFire13 wrote:
| Typst is also a programming language for document production,
| however they made the decision to make the code side an
| actual scripting language, which makes writing custom logic
| much easier than in Latex.
| mr_mitm wrote:
| I can't wait for LaTeX to go away in favor of Typst. The
| experience is night and day. Very impressed with their work.
|
| I've been using Jinja2 templates to generate TeX files, but Typst
| can take a JSON over the command line and is easy to use and
| powerful enough that I can completely remove the Python step.
|
| Not to speak of the compile time that is measured in
| milliseconds.
| Winsaucerer wrote:
| Yes, the scripting is very nice. At first, I played around with
| Go templates to generate the Typst templates, since that is
| what I was used to doing with LaTeX. It was very nice to
| discover it allows you to use JSON with its scripting engine
| directly pretty easily.
| Ilasky wrote:
| I love Typst. It's especially good for dealing with programmatic
| input as the --input flag can take json. [0] Then, in the file
| it's easy to get the json with the dedicated json.decode()
| function. Super easy to get solid results. Swapped to it from
| LaTeX in my own project [1]
|
| [0] https://typst.app/docs/reference/foundations/sys/
|
| [1] https://resgen.app
| MaxBarraclough wrote:
| I'm surprised to see that HTML output is currently in progress,
| and was not a core feature from the start. [0]
|
| LaTeX's awkward relationship with the web seems like something a
| competing greenfield project would try to nail right out of the
| gate (to mix metaphors painfully).
|
| [0] https://github.com/typst/typst/issues/721
| Kinrany wrote:
| Someone mentioned that pandoc works decently for this.
| alphabeta2024 wrote:
| It does not.
| ykonstant wrote:
| I am using pandoc to transfer some of my notes to the web:
| https://ykonstant1.github.io/power-draft.html
| nicf wrote:
| I've been doing something similar, and it looks like you've
| managed to solve a problem I've been unable to: how did you
| get theorem and section numbering to work right?
| hgyjnbdet wrote:
| Not the OP but I use pandoc-crossref for this:
| https://lierdakil.github.io/pandoc-crossref/
| ykonstant wrote:
| Nothing special; here is the pandoc command I use to
| transform tex without tikz: for input in
| *.tex; do pandoc "${input}" \
| --from latex \ --to html
| \ --pdf-engine=latexmk \
| --css="styles/texstyle.css" \
| --standalone \ --mathjax
| \ --toc \
| --number-sections \
| --output="${input%".tex"}.html" ; done
|
| My pandoc version is: pandoc 3.1.9
| Features: +server +lua Scripting engine: Lua 5.4
| CJefferson wrote:
| Yes, latex's HTML output is fairly good nowadays, after a lot
| of people made very heroic efforts to put it in a system never
| intended to support it.
|
| Starting a new markup system with no plan for making accessible
| documents was, in my opinion, a very bad idea. I refuse to use
| typst until it can produce accessible documents.
| nanna wrote:
| > Yes, latex's HTML output is fairly good nowadays, after a
| lot of people made very heroic efforts to put it in a system
| never intended to support it.
|
| Mind saying more? Didn't know there'd been progress here.
| amai wrote:
| Have a look at https://ctan.org/pkg/lwarp and
| https://math.nist.gov/~BMiller/LaTeXML/ .
| delta_p_delta_x wrote:
| lwarp's output is phenomenal. Both https://tikz.dev/ and
| https://tikz.dev/pgfplots/ are rendered with lwarp and I
| daresay they are a noticeable improvement over the PDF
| equivalents.
| slashdave wrote:
| I assume you know that tex predates the web by many years?
| IshKebab wrote:
| Nothing in his comment suggested he was unaware of that so
| I'm not sure why you're asking.
| kerkeslager wrote:
| So? If I'm a modern user who needs my typesetting system to
| generate HTML, I'm not going to "forgive" a typesetting
| system because it's older than the web and use it even though
| it doesn't do what I need.
| slashdave wrote:
| I am just trying to understand how you expect a typesetting
| system to be designed around a paradigm that doesn't exist
| yet.
| CBarkleyU wrote:
| While GP is not here, can you make me understand how
| exactly you deduced that GP expected TeX to be designed
| around said paradigm?
| kerkeslager wrote:
| I don't expect LaTeX to be designed around a paradigm
| that didn't exist when LaTeX created.
|
| Why do you think anyone expects that?
|
| Why should anyone looking for a typesetting tool care
| when it was designed?
|
| Why don't you use a Commodore64? I know it doesn't do
| anything you need it to do, but you have to cut it some
| slack, it was designed before any of the things you need
| to do existed!
| setr wrote:
| GP was complaining that new modern Tex competitors should
| be designing for this, to correct the fact that Tex
| doesn't.
| cactusfrog wrote:
| Yes, this is one of the major problems with this. I don't like
| pdfs
| constantcrying wrote:
| Typst wants to compete with LaTeX.
|
| They both face the same problem, namely that the web and paper
| work completely differently and there are untranslatable
| concepts. So you have to define some way in which your
| typesetting gracefully settles into a different environment.
|
| If typst had targeted html immediately it certainly would have
| made their life _a lot_ easier, but it would have been nothing
| more than an overly complex site generator. Targeting PDF first
| means that they actually want to compete with LaTeX.
| Shorel wrote:
| I would prefer some tool that generates better e-books, like
| an improved ePub format with better equations and tables.
|
| This division between web and PDF is meaningless to me. The
| ePub format is a book format based on Web technologies.
|
| A better book format is to the benefit of everyone. To
| believe HTML can only make websites is counterproductive
| here.
|
| I make PFDs in LaTeX because I am asked to use it, not
| because I believe it is a good format.
| constantcrying wrote:
| PDFs are a digital recreation of paper documents, with all
| the drawbacks of that.
|
| Targeting ePub is essentially the same as targeting the
| web, the distinction between having the file locally or
| retrieving it from a server seems entirely meaningless in
| this context.
|
| >not because I believe it is a good format.
|
| It is a pretty much perfect format within the constraints.
| renerick wrote:
| I make TTRPG character sheets with Typst. No only they look great
| with perfect page layout, the programming capabilities allow to
| compute everything from ability scores automatically, like Excel.
| It's really well designed, and fast too, VS Code integration just
| works (for me at least)
| kkfx wrote:
| LaTeX is not just a set of macros over TeX to produce (nowadays)
| some pdf, it's a very big library of ready-to-use packages for
| pretty anything, that's VERY hard to "substitute".
|
| You want inspiration for some strange table layouts? There are
| gazillion ready made; some graph? TiKz/PGF have gazillions of
| ready made examples... Want a programming language in the middle?
| Python, Lua etc can be embedded straight away.
|
| So far I've seen few tentative to "replace or hide LaTeX", from
| the old DocBook to ConTeXt, no one succeed simply because of all
| the LaTeX already made and easy to import. Having alternatives,
| especially seen the actual "fragmented" development is nice, but
| honestly I doubt it can take off. Proprietary products are fast
| to wane in popularity if a serious competitor pops up because the
| users does not own them, FLOSS are much calmer since anyone can
| grab a piece and integrate ideas of someone else without the need
| to switch.
| kleiba wrote:
| Exactly. It's not too difficult to imagine replacing LaTeX for
| some fairly straight-forward documents. But just by casually
| browsing tex.stackexchange.com, you'll soon find out that
| people use LaTeX for an amazingly wide range of different
| things, and it's capable of serving many, many edge cases very
| well. To be on par with that is a very hard goal. Let's not
| forget, LaTeX has been around forever, and consequently has
| grown into an incredible complex and varied ecosystem.
| jonnycomputer wrote:
| I mean, the same is true for Emacs. But that hasn't stopped
| other editors (e.g. VSCode) from developing large vibrant
| communities of users and tooling.
| JohnKemeny wrote:
| But Emacs isn't a requirement by half the STEM research
| community, LaTeX is.
|
| Typst is not replacing LaTeX in general and should stop
| advertising being a LaTeX replacement. It isn't a
| competitor.
| thomas34298 wrote:
| Not everything revolves around scientific journals and
| their archaic rules. For my team Typst was a perfect
| LaTeX replacement and we've been happy ever since we
| switched. It is easier to understand, has faster compile
| times and is more powerful without enabling shell escape.
| However, we're not in the business of writing scientific
| papers, we write technical reports for our customers. If
| it wasn't advertised as a LaTeX replacement, we might
| never have found out about it.
| kerkeslager wrote:
| > Want a programming language in the middle? Python, Lua etc
| can be embedded straight away.
|
| After using templating languages in Python, yes, I always want
| this when using LaTeX. And as of ~2 years ago when I last tried
| this, while sure, I could embed Python in the middle, the
| interface for interacting with LaTeX via the embedded Python
| was anemic enough to be not useful. Maybe something had changed
| in the last 2 years, but if so, it's not more mature.
|
| Example: I wanted to have a daily meditation book, where
| \chapter{Title} would insert the dates in order with the title
| of the meditation, instead of chapter numbers, also inserting a
| table of contents entry with the dates. What I _didn 't_ want
| was to have to go through and change dates if I added a
| meditation in the middle, or swapped the order of meditations.
| I'm not picky, I would've been happy to use \section{Title} or
| \meditation{Title}, or script a solution.
|
| What happened was I spent probably 6 hours of research and
| never found a solution integrated into LaTeX. I did eventually
| write a script in Python that naively parsed the chapter titles
| and changed them in-placed in the LaTeX code, but that meant I
| had to regenerate the dates as a separate task.
|
| Note that this took me about 5 minutes to figure out with
| Typst's integrated scripting language.
| mr-karan wrote:
| Typst has been pretty amazing, and at my organization, we're very
| happy with it. We needed to generate over 1.5 million PDFs every
| night and experimented with various solutions--from Puppeteer for
| HTML to PDF conversions, to pdflatex and lualatex. Typst has been
| several orders of magnitude faster and has a lighter resource
| footprint. Also, templating the PDFs in LaTeX wasn't a pleasant
| developer experience, but with Typst templates, it has been quite
| intuitive.
|
| We've written more about this large-scale PDF generation stack in
| our blog here: https://zerodha.tech/blog/1-5-million-pdfs-
| in-25-minutes
| sitkack wrote:
| What is the use case for generating that many PDFs?
| mr-karan wrote:
| Regulatory requirements mandate that. Stock brokers in India
| are required to generate this document called "Contract
| Notes" which includes all the trades done by the user on the
| stock exchanges. It also contains a breakdown of all charges
| incurred by the user (brokerage, various taxes etc). And this
| has to be emailed to every user before the next trading
| session begins.
| bjourne wrote:
| There are of course way more efficient methods for
| generating templated pdfs than using a typesetter.
| cameroncooper wrote:
| I'm interested to hear what you would propose.
| abound wrote:
| Not sure what GP had in mind, but one can
| programmatically generate PDFs directly, without using
| something like Typst as a "middleman".
| the_mitsuhiko wrote:
| Have you tried doing that? It's no fun at all and far
| from easy. I don't quite see a benefit in doing it
| without some utility.
| a57721 wrote:
| Besides, the generation of PDF reports is usually
| decoupled from the templates, so you will have to work on
| your own "middleman".
| wolfi1 wrote:
| I guess some webkit solution like wkhtmltopdf
| mr_mitm wrote:
| How is that more efficient than Typst exactly?
| bjourne wrote:
| Apache iText, for example.
| IshKebab wrote:
| Does the law specify PDF? I would have thought pain text or
| even HTML would be sufficient.
| the_mitsuhiko wrote:
| I don't know the situation in India but brokers in
| Austria and Germany do the same. The law does not
| stipulate the format but PDF is what everyone uses. I
| assume it's because it can be signed and archived and
| will outlast pretty much anything. You need to keep these
| for 7 years.
| mr-karan wrote:
| Yes, in India, the law mandates that ECNs (electronic
| contract notes) need to be digitally signed with a valid
| certifying authority. While it's true that XML/docx/xls
| files could also support digital signatures, but I think
| PDFs are prevalent and also allow clients to verify this
| on their end, quite easily.
| yukeabu wrote:
| PDF is less likely to contain executable malicious code
| than other formats.
| radicality wrote:
| Is it? More so than say .csv file ?
|
| I was under the impressions that pdfs are not that safe.
| I thought they can do stuff like execute a subset of
| PostScript and Javascript.
| yukeabu wrote:
| Look, when it comes to corporate reporting, PDFs are
| pretty much the gold standard. Sure, they've got some
| potential security issues, but any decent company's IT
| department has them well in hand.
|
| Think about it - you want your reports to look sharp,
| right? PDFs deliver that professional look every time, no
| matter who opens them or on what device. Plus, they've
| got all those nifty features like password protection and
| digital signatures that the big guys love.
|
| CSV files? They're great for crunching numbers, but let's
| face it - they look about as exciting as a blank wall.
| Try sending a CSV report to the board of directors and
| watch their eyes glaze over.
|
| So, yes, for reporting in a company that's got its
| security act together, PDFs are your best bet. They're
| like the well-dressed, security-savvy cousin of other
| file formats - they look good and keep things safe.
| prmoustache wrote:
| More than plain text? I doubt so.
| 1oooqooq wrote:
| common people don't talk about plain text. what are you?
| a hacker?!?
| prmoustache wrote:
| I mean I guess you don't care as long as the file is
| signed if it is just some regulatory stuff that barely
| anyone would ever read anyway.
| happimess wrote:
| This is a really great write up. Kudos for the obvious effort,
| both on the technical side and sharing the process with the
| rest of us.
| dudus wrote:
| Have you tried reportlab as well? It was a good solution when I
| had to deal with a similar problem many moons ago. Not quite
| the same volume you have but still.
| kerkeslager wrote:
| Having used ReportLab a bunch, I'd agree it's a good
| solution, but not maybe on the more mediocre side of good.
| Generating LaTeX was a better solution for me, and while I
| haven't used it, Typst looks a lot better.
| znpy wrote:
| Just wondering: did your organisation contribute anything back
| to the project, or supported it financially in any way?
| mr-karan wrote:
| Hey. Yes we did support them financially from our FOSS fund.
| We'll be happy to do it once more as well.
| mstijak wrote:
| Never heard that someone is generating PDF documents at that
| pace. I'm working on a product that is used for mass PDF
| reporting based on Puppeteer. With nightly jobs, caching, and
| parallel processing, the performance is ok.
|
| https://www.cx-reports.com
| tecleandor wrote:
| I think we don't reach that much quantity, but we do a hefty
| number. What for? Invoices!
|
| We're having problems because until now PDFs are being
| generated by the ERP system, and it can't keep pace. I know
| there's a Dev team working on a microservice for PDF
| generation, but never thinked about doing it with Typst.
|
| I think I'm going to send them @mr-karan link.
| 1oooqooq wrote:
| pdf/ps can easily be created in a way that data for text
| and qr code fields are easily in plain text. seems like
| yall focusing too much on the higher level tools instead of
| what's right in front of you.
| mstijak wrote:
| Company branding is an important aspect of PDF creation
| that many tools struggle to handle correctly. PDF
| documents often need to include logos, company colors,
| fonts, and other branding elements. Puppeteer is popular
| because you can control these aspects through CSS.
| However, Puppeteer can be challenging to work with for
| larger documents, as each change requires programming
| effort or when your software needs to needs to serve
| multiple clients each with different requirements.
| tecleandor wrote:
| Yep, it's mostly about branding and control. It needs
| certain concrete layout and logos, and has to be
| relatively easy to change them.
|
| We also render shipping labels in PDF, and we have to be
| VERY strict with that. But we're still not touching that,
| as that process is not at slow and problematic as the
| invoicing one.
| 1oooqooq wrote:
| how having the value and name in an invoice as plain text
| affect branding? or do you mean there client branding is
| added to the invoice??
|
| the end result when you open the file is still a regular
| pdf. it's just encoded with some areas unpacked
| tecleandor wrote:
| It's not about the plaintext, but about the layout,
| design and logos. At least in our case.
| 1oooqooq wrote:
| so why you bring that up on a thread that had nothing to
| with layout? I'm honestly confused
| iamgopal wrote:
| I was reading second sentence, and I knew it was zerodha. It's
| good to see more open source in your tech stack.
| stevekemp wrote:
| Thanks for your writeup, that was exceptionally well-presented.
| humanfromearth9 wrote:
| So, anyone using it?
| renerick wrote:
| Hypermedia.Systems does - https://dz4k.com/2024/new-hypermedia-
| systems/
|
| https://hypermedia.systems
| bucephalos wrote:
| Nowadays, I use Latex mainly for letters using the great KOMA
| package. I wouldn't mind switching to a markdown based system for
| that. Would Typst work to produce DIN format letters?
| mr_mitm wrote:
| Yes: https://typst.app/universe/package/letter-pro/
| bucephalos wrote:
| Awesome, thanks!
| ThinkBeat wrote:
| Where does it get its font from?
| chambored wrote:
| I believe you can run a command to point its font options to a
| directory.
| pgen wrote:
| I personally prefer ConTeXt
| (https://wiki.contextgarden.net/ConTeXt_Standalone).
|
| It's comparable to LaTeX, but better in my opinion.
| nanna wrote:
| I could never get my head around the use case for ConTeXt. It
| seemed like LaTeX minus defaults that have been defined by
| typographers and the massive ecosystem. Care to say more?
| karencarits wrote:
| I guess this is a competitor to services such as overleaf [1] and
| codimd [2]. Although this is yet another syntax, it seems to be
| supported by pandoc [3]. Lately, I have been using Quarto [4]
| more and more as I program in R, which also produces very nice
| outputs, especially HTML. But none of these solve the academic
| usage problems of (1) producing nice diffs for reviewers, and (2)
| can easily be shared with, and commented by, non-technical
| collaborators. Thus, I fear Word will be difficult to replace for
| many years, at least in my field, for scientific writing
|
| [1] https://github.com/overleaf/overleaf
|
| [2] https://github.com/hackmdio/codimd
|
| [3] https://pandoc.org/typst-property-output.html
|
| [4] https://quarto.org/
| countrymile wrote:
| I've been using quarto a lot too. I've found the typst pdf
| travel output to be a bit rougher than latex pdf when using GT.
| Hopefully something that will get fixed.
| Aerbil313 wrote:
| I'm a college student and I use Typst in school all the time. I
| know I should just use Google Docs/Sheets, but because it's code
| instead of a WYSIWYG editor it's very easy to create reusable and
| consistent styles for reports and presentations, and saves time
| on the long run. (I use polylux module for slides.) Once you get
| past the learning curve (10-15 hrs if you nosedive) it's
| incredibly easy to create professional stuff.
| spidersouris wrote:
| touying[1] seems quite great to create slides too.
|
| [1] https://typst.app/universe/package/touying/
| xyst wrote:
| This is very easy to use compared to latex. My latex resume (or
| the template I was using) was thousands of lines and had several
| imports of custom classes.
|
| Re-did my resume using one of their templates, and it's much
| easier to maintain now.
| rochak wrote:
| Have been using it for a while. Can't overstate how much better
| the experience has been compared to LaTeX. As someone who had to
| use LaTeX not out of choice, I'm so grateful this exists so that
| I can no longer bother to decipher the mess of LateX.
| spacebuffer wrote:
| This is very interesting, seems to be like LaTex + a whole lot
| more.
|
| I need to generate udemy-style certificates for a project I am
| working on. are there any guides on generating PDFs with typst?
| byteplane wrote:
| I'd be happy if this takes off just for the fact that their
| default typeface (or at least the one shown on the website) is so
| much better than "Computer Modern"!
| anserin wrote:
| The main problem I have with Typst compared with LaTeX is that it
| doesn't handle basic fine typographic features, such as the
| different types of spacing in mathematical mode (mathop, mathbin,
| mathrel, etc.) or the size of delimiters (big, bigg, etc.)
| StableAlkyne wrote:
| It also seems to have problems with accessibility, based on
| this thread - https://github.com/typst/typst/issues/133
|
| But then again, apparently so does LaTeX
| xkevio wrote:
| Am I misunderstanding what exactly you are looking for? You can
| change the spacing in math mode of symbols/operators with
| https://typst.app/docs/reference/math/class/ and delimiter size
| with https://typst.app/docs/reference/math/lr#functions-lr (or
| automatically).
| anserin wrote:
| I didn't know about math classes, thank you for the reference
|
| The issue I have with delimiters is that there is no option
| for "big", but only for "140%" or whatever, making it harder
| to be consistent Someone created an issue on this on GitHub
| if I remember correctly
|
| And automatically chosen sizes are often too large
| laurmaedje wrote:
| Good point! lr should support lengths in addition to
| ratios. Should be easy to add.
| xkevio wrote:
| Ah, yeah fair enough! I was confused thinking that you were
| unaware of the existence of the functionality as a whole.
| Well, as laurmaedje (one of the main devs) said below, it
| should be easy to add, though it seems difficult to find
| which size values `big`, `bigg` and so on exactly
| represent.
| amai wrote:
| Quarto already supports typst: https://quarto.org/docs/output-
| formats/typst.html
| amai wrote:
| Unfortunately out of the box typst is missing an important layout
| features compared to Latex: the auto-generation of headers
| (showing the section name in the header). There are some packages
| that help you with that:
|
| - https://typst.app/universe/package/hydra,
|
| - https://typst.app/universe/package/chic-hdr
|
| - https://typst.app/universe/package/wonderous-book
|
| However I believe this functionality should be available in the
| typst core.
| fbdab103 wrote:
| Practically nothing in Latex comes out of the box. Sure, you
| can bang out markdown-esque formatted text, but the moment you
| need something more complicated, say URLs, graphics, resize the
| margins, etc you are likely going to be pulling in a package.
|
| No true scotsman and all that, but I suspect few documents in
| the wild are bare Latex.
| amai wrote:
| But the feature I'm talking about comes out of the box. One
| just writes
|
| \documentclass[twoside]{article}
|
| \pagestyle{headings}
|
| in LaTeX. And this also does the right thing on special pages
| like table of content, appendix, bibliography etc.
|
| Implementing all that in Typst is quite a hassle.
| delta_p_delta_x wrote:
| The 'La' in 'LaTeX' stands for 'Lamport'. Leslie Lamport
| set up additional macros atop the base TeX language to make
| life easier. To this day LaTeX code can still be compiled
| with `pdftex` (note, no 'la' there).
|
| The `article` document class is actually some `article.cls`
| file that resides somewhere in your TeX install root, is
| loaded, and implements macros such as `/title`, `/section`,
| `subsection`, and so on. All LaTeX eventually expands into
| a pile of TeX macros that are evaluated.
|
| All this is to say... LaTeX comes with the templates,
| you've been using one all this while.
| amai wrote:
| So I think Typst should come with a few default templates
| like Latex to make writing easier for beginners.
| constantcrying wrote:
| Typst comes as a blank slate. You _want_ to start with
| template, which defines things for you.
|
| The difference between LaTeX and Typst is that LaTeX wants you
| to define a template with the "documentclass", if you want the
| same experience in Typst you want to setup typst with a
| template, there the headings will be defined for you already.
|
| >However I believe this functionality should be available in
| the typst core.
|
| You can trivially define headings in typst without using
| packages.
| kerkeslager wrote:
| This is the sort of thing that I'm excited about because it
| solves problems I have, but can't really use for much because I'm
| not sure if it will exist in a year.
| notpushkin wrote:
| I mean, the compiler is open source, so if you download it it
| will exist (even if no new features / bugfixes are released).
| trostaft wrote:
| I'm following the progress of this package, I would not mind a
| more modern successor to LaTeX. I'm an academic, and I actually
| do not mind LaTeX. I find actually writing LaTeX to be fairly
| natural. But every time I come to the programmatic interface I
| feel like there's a lot of room for improvement and that's the
| most exciting aspect of typst.
|
| I cannot, reasonably, start using this for work until journals
| begin accepting papers in the format. But I am following until
| either that starts happening, or some workaround exists.
| fastasucan wrote:
| Have you tried out Quarto?
| chambored wrote:
| I've been using Quarto for a few years now. It's quite a
| breeze to use. Highly recommend to anyone looking to publish
| technical writing on their static site.
| __mharrison__ wrote:
| I would love to replace latex but I only use it for making
| physical books and none of the replacements have the features
| needed...
| rossant wrote:
| Which features?
| Duanemclemore wrote:
| Oh it's pandoc compatible which means my favorite LaTeX trick is
| possible - writing in an IDE then using pandoc to convert to icml
| for linking inside InDesign.
| hgyjnbdet wrote:
| I saw this come up today in a different thread.
|
| I'm a mature undergrad, I've never used LaTeX, actively avoided
| it in fact and am forced to produce word documents. My current
| workflow is pandoc style markdown and obviously pandoc for
| conversion, with zotero for citations. I make use of pandoc-
| crossref for figures, tables, sections, etc.
|
| I'm hopefully moving to a different uni for a masters this year.
| Can anyone who uses typst comment on whether I should consider
| moving from my fairly complicated workflow to typst?
| bitvoid wrote:
| You may be limited for your thesis. My grad program required us
| to conform to either a Word or LaTeX template, of which I found
| the latter actually much easier to deal with. I just kept my
| chapters in separate files that are inputted into the template.
|
| If you're asking for other assignments, I'd actually recommend
| Quarto [1]. It's basically a streamlined version of your
| current workflow. The other benefit is that it can convert your
| markdown to Typst if you decide to switch over in the future.
|
| 1: https://quarto.org
| mohamez wrote:
| The best thing about Typst is that it's intuitive.
| zmmmmm wrote:
| We use a custom tool that bases everything on markdown for this
| type of thing. It also integrates Jupyter notebooks. It is mostly
| very effective but the limitations of Markdown certainly grate.
| Having said that the best thing by far is that it's automatically
| viewable in Gitlab/Github in source form. This doesn't look like
| it would fare all that well.
| aragilar wrote:
| Does this have support for macros? It doesn't appear to, and so
| feels a bit like another variant on markdown (with its own
| special syntax)? It's not clear to me why I'd use this, compared
| with RST (where I can generate LaTeX or HTML, and script with
| python)?
| nmca wrote:
| It has functions which replace macros. One would use it instead
| of latex because it is immeasurably faster and more sane.
| constantcrying wrote:
| No, it has no macros, that is its greatest selling point.
| Instead you can use an embedded programming language which will
| look familiar to anyone who has some experience with software
| development to script it.
|
| Replacing TeX's abysmal macro expansion language with a
| reasonably normal programming language is one of the reasons
| you would use it. Look at the example on their GitHub to see
| how the language works in a document.
| ARandomerDude wrote:
| This looks really great and I'll give it a try. I keep thinking,
| however:
|
| My guessed probability that LaTex is free and maintained in 15
| years: 99.9999%
|
| My guessed probability that $OTHER_NEW_TOOL is free and
| maintained in 15 years: 5%
| viraptor wrote:
| The curse of early-and-good-enough systems. It's the same for
| bash and a few other things. Not enough pain points to replace
| them even though there's lots of better alternatives.
| jltsiren wrote:
| The curse of support.
|
| If you need something that will be supported for the next
| 20/30/50/100 years, you pick an already established product
| that is widely used and does not depend on any single
| organization. You can't rely on volunteer projects, as
| volunteers have no duty to maintain and support the product.
| And you can't rely on anything made by a single company, as
| companies lose interest and die all the time.
| mr_mitm wrote:
| LaTeX's support is already problematic. Most people just
| don't use it in sufficient intensity to notice. We produce
| thousands of (mostly) custom written technical reports a
| year using LaTeX and there are all sorts of subtle issues
| cropping up. It's a distribution (edit: or at least texlive
| is) of many, many packages from many developers, and
| maintenance can be spotty and vary. Unlike some people
| would like to believe, stuff breaks all the time.
|
| Check this out for example: https://github.com/tabu-issues-
| for-future-maintainer/tabu
|
| This used to be the most recommended package for tables.
|
| This bug is still not fixed after at least 9 years AFAIK:
| https://tex.stackexchange.com/questions/203629/longtable-
| and...
|
| It affects us regularly.
|
| I'm not even going to comment on the fact that all of the
| following packages provide some sort of tabular feature:
| array, table, tabu, tabular, tabularx, longtable,
| supertabular, longtabu, xltabular, lxtable, booktabs,
| tabularray, ctable. Good luck figuring out which one does
| what you need and has the least side effects with
| everything else.
|
| Also, while I'm not familiar with the internals of the
| LaTeX project, I keep reading the same names, most of which
| appear to be getting closer and closer to retirement. I
| wonder if suitable successors will pick up the task of
| maintaining LaTeX in the future.
| blackbrokkoli wrote:
| Also the curse of paradigm.
|
| Making tools libre as a matter of course and mailing people
| checks for bug finds just rings different than today's
| dominant paradigm of landing pages, conversion rates, social
| media tie-ins and for-profit non-profits...
| drsopp wrote:
| From the first example, I don't understand from the syntax why
| the first formula becomes inlined while the second one is
| centered on the page.
| constantcrying wrote:
| It's the space after and before the $. A bit weird I guess, but
| I think it makes some visual sense.
| hgyjnbdet wrote:
| Quarto appears a popular alternative, out of interest is anyone
| using Zettlr?
|
| https://www.zettlr.com/
| 8n4vidtmkvmk wrote:
| Can I use this to generate PDF invoices from PHP?
|
| I've been searching for a good solution for the past 15 years.
| Never been happy with the solutions, and my PDFs are always very
| ugly.
| tehbeard wrote:
| Used it in a recent PHP project, only real caveat/issue I ran
| into is you can't pipe out to STDOUT on windows:
|
| Wrapper class I wrote to handle it: <https://gist.github.com/te
| hbeard/a54a2c77b4b8bf1af26920ce7a7...>
| 8n4vidtmkvmk wrote:
| That's awesome, thanks!
|
| I need to print big tables of data though, I remember hitting
| limits before when I've tried to pass too much as shell args.
| Shorel wrote:
| Two things interest me from this project:
|
| More templates than LaTeX. I have made PDF presentations in
| LaTeX, which look good, but they all look the same. Some variety
| is good.
|
| Unicode chars support. I prefer to type a instead of \alpha.
|
| That's it, both things together will make a LaTeX killer for me.
| enriquto wrote:
| > Unicode chars support. I prefer to type a instead of \alpha.
|
| This is not done by default by LaTeX, but if you can bear to
| \usepackage{unicode-math} then it's readily available. A life
| changer!
|
| Regarding presentations, what do you mean exactly? There are a
| lot of weirdly different beamer themes. You can even put a
| single verbatim block inside each slide and you'll just have a
| "text mode" presentation, if that is your thing.
| Shorel wrote:
| Thank you about the unicode-math package. I will surely use
| it.
|
| About the presentations: All beamer themes look similar to
| me.
|
| Open PowerPoint template gallery to see how different the
| designs can really be!
| summarity wrote:
| I can't get past the sign-up form: "503 Service Temporarily
| Unavailable"
| uger wrote:
| I love Typst for text and equations, but I find that it is taking
| me time to adapt to their table syntax and be able to make tables
| similar to booktabs. I'm hoping that Estout or Modelsummary will
| be able to write Typst tables with complex formatting soon.
| jbd0 wrote:
| Seems like a pain to install. I'm looking forward to this being
| packaged for Debian.
| isatty wrote:
| Disclaimer: I haven't tried the syntax but it doesn't scream
| "easier" to me. Latex doesn't either.
|
| Plus this doesn't seem to compile down to latex so I also lose
| the engine. From experience, latex makes beautiful documents and
| choices which I'll always prefer over ease of use.
| thefringthing wrote:
| Just don't try to put a footnote in a heading. I'll keep using
| LaTeX until Typst is less buggy.
| ttul wrote:
| Working as an intern in 1999, I was tasked with writing a
| standards document for VoIP telephones for the TIA working group
| working on this space. The standards organization had a Word
| template that everyone used, but as an engineering student, I had
| been working with and loving LaTex for some time and so naturally
| I thought... "why not just use LaTex? The final output will be in
| PDF anyway and the formatting will be better."
|
| The LaTex output was indeed better. My boss loved my work and had
| no idea that I wasn't using Word. Feedback from the working group
| members was also positive. Wow, this kid has real talent! As a
| startup, making a positive impression on the giant companies
| represented in the working group was extremely important for the
| future of the company, if not its survival.
|
| Unfortunately for me, one day my boss said, "could you send that
| Word doc over to big-whig so-and-so at massive-company-we-might-
| be-acquired-by? They want to use it as a template for a new
| document they're writing."
|
| I got that sinking feeling similar to when my mom found out my
| friend and I had peed in my closet as an experiment at age four.
|
| I then hired a friend to work all weekend painstakingly rewriting
| it in Word. Boss man got the document. Company was acquired for
| $100M 18 months later.
|
| Either way, LaTex still looks 1,000x better than Word.
| owenpalmer wrote:
| This is a Typst + Neovim live preview project:
| https://github.com/chomosuke/typst-preview.nvim
|
| It looks similar to Gilles Castel's famous note-taking setup:
|
| https://castel.dev/post/lecture-notes-1/
|
| I would love to see someone combine this with Anki for quick math
| flashcard creation
___________________________________________________________________
(page generated 2024-07-21 23:12 UTC)