4 ms·
> The selling point seems to be that this is more similar to Markdown. The problem is that extending Markdown syntax gets messy. #figure( image("ima
by Animats 2y ago
> The selling point seems to be that this is more similar to Markdown.
The problem is that extending Markdown syntax gets messy.
#figure(
image("image.jpg", width: 70%),
caption: [
Observe the image in the picture
],
) <figure>
This is kind of a strange blend of Markdown, CSS, JSON, and HTML. TeX at least has a consistent syntax.
- airstrike 2y agoStrange to the untrained eye, perhaps. To me that just looks like a function. In a long document I recently wrote, I defined a custom function #let img(filepath, inset: 0.5em, caption: none) = { figure( box(inset: inset, stroke: 0.5pt + gray, image(filepath)), caption: caption ); } and just used it like: #img("images/excel-5.0.png", caption: "Microsoft Excel 5.0 was released in 1993.") edit: fixed unused inset param
- smartmic 2y agoThese 6 lines actually put me off. Probably I have to read more about Typst syntax but, same for me, consistent syntax which covers necessary complexity wins over bending a markup language for purposes for which it was never intended.
- josephg 2y agoIt’s best not to think of it as a markup language. It’s a programming language designed around the needs of outputting pdfs. Structurally it’s like a modern, nice version of php, only it’s built for academic articles rather than emitting websites. The code snippet there packs in about 8 typst concepts all at once. It’s like if someone showed off how “simple” c++ is by showing some template-heavy magic. It’s straightforward once you’ve spent time with the language, but it’s a pretty terrible place to start learning typst. (That example shows expression mode, block mode, function calling, tags, named arguments, and probably more. Whew!)
- gauge_field 2y agoThat is a great analogy. When I wrote my note/hws in latex, I had the urge to go look for a package more frequently. When I started converting those docs into typst, I was able to hack around more easily, it really did feel like a modern programming language that has great error messages and that I enjoyed writing in. It did not feel complex, especially with the help of compiler errors messages
- __mharrison__ 2y agoIt's a little odd at first. I would recommend reading through the tutorial (which is quite good) and you might start to see some of the method to the madness.
- orangeboats 2y agoIt may be similar to Markdown if you squint your eyes real hard, but it's not Markdown. Furthermore, quoting a random snippet without any elaboration is unhelpful and only serves to confuse people (as it already did for the other comment!) # means "evaluate". figure(...) is the function being evaluated. The syntax inside figure(...) is fairly regular, not too different from what you'd see in typical programming languages (but with a document-oriented twist like the %). <figure> may seem to be related syntatically to #figure(...), but it's not. It's just a label. Like an HTML div tag with id="figure". It can very well be changed to <foo> in your example and it'd still work.
- SkiFire13 2y agoWas do you find inconsistent here? It seems pretty consistent to me, except maybe the <figure>
- chrisweekly 2y agoand that <figure> tag is kind of moot -- as another commenter mentioned, it could have been some other html tag like a div
- SkiFire13 2y agoIt's not a tag, there aren't even HTML/XML tags in Typst. The effect of that <figure> is giving the #figure(...) element the label `figure` (i.e. the name is what's inside the <>). Probably using the label "figure" was not the best choice for an example, something like <my_figure> would have been a bit less confusing showing that it is an arbitrary name/id that you choose. Edit: and I think you also misinterpreted the other comment about the <div>. It wasn't about using <div> in place of <figure>, but rather that using <figure> in typst does the same thing as id="figure" in HTML.
- chrisweekly 2y agoI stand corrected. Thanks for the detailed info.