DEV Community

Cover image for The Happenings with TexCreate v3
Mustafif
Mustafif

Posted on

The Happenings with TexCreate v3

The latest TexCreate version is v2.2.1 and that was released over 9 months ago. So considering that the transition from TexCreate v1 to 2 was a few months of development, why is this taking so long?

A Focus on Template Modularity

The known flaw I had with the current version with TexCreate is "hard coding" the templates inside the application. For those unaware, TexCreate is a LaTeX project manager that utilizes prebuilt templates to build projects for various needs. In v2 I transitioned to using a native Rust library tex-rs to build the LaTeX code, but the library wasn't modular itself.

So what do we do? My first focus was building a library I can expand, and that's where the development with texcore started. After 6 months of development, it is what I consider ready for TexCreate, the latest version at the time of writing is v0.4.10. The library can be found in crates.io. The interesting new feature in v0.4 is the TexCreate Template feature which provides the template module with the following type:

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, PartialOrd)]
pub struct Template {
    pub name: String,
    pub description: String,
    pub version: Version,
    element_list: RefCell<ElementList<Any>>,
}
Enter fullscreen mode Exit fullscreen mode

Custom Templates?

At the current moment I plan to only have the application use first-party templates I develop, but there are plans to add functionality for custom templates.

How would that work? Well when TexCreate is initialized it will create a directory in $HOME/.texcreate. The current plan is to keep all templates JSON files there, but what can happen is that inside of the .texcreate directory we may have the following structure:

.texcreate/
     mkproj/
        Basic.json
     custom/
        Foo.json 
Enter fullscreen mode Exit fullscreen mode

A sample Template may look like the following:

{
  "name": "Basic",
  "description": "This is a basic LaTeX document",
  "version": {
    "major": 1,
    "minor": 0,
    "patch": 0
  },
  "element_list": {
    "metadata": {
      "author": "author",
      "date": "date",
      "title": "title",
      "fontsize": 11,
      "doc_class": "article",
      "maketitle": true
    },
    "list": [
      {
        "value": {
          "value": "\\pagenumbering{arabic}",
          "type_": "T_Custom",
          "level": "Document",
          "header_level": null,
          "text_type": null,
          "list_type": null,
          "items": null,
          "elements": null
        },
        "type_": "T_Custom",
        "level": "Document"
      },
      {
        "value": {
          "value": "\\newpage",
          "type_": "T_Custom",
          "level": "Document",
          "header_level": null,
          "text_type": null,
          "list_type": null,
          "items": null,
          "elements": null
        },
        "type_": "T_Custom",
        "level": "Document"
      },
      {
        "value": {
          "value": "amsmath",
          "type_": "T_Package",
          "level": null,
          "header_level": null,
          "text_type": null,
          "list_type": null,
          "items": null,
          "elements": null
        },
        "type_": "T_Package",
        "level": "Packages"
      }
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

The following Template then would be processed and converted into the following TeX code:

\documentclass[11pt, letterpaper]{article}
\title{title}
\author{author}
\date{date}
\usepackage{amsmath}
\begin{document}
\maketitle
\pagenumbering{arabic}
\newpage
\end{document}
Enter fullscreen mode Exit fullscreen mode

What's Happening Now...

Currently I am developing texcreate-services which aims to be a suite of applications to manage the templates for TexCreate. This part of the project may not be opensource because it could become a vulnerability to the project and considering its the core function I rather not have that risk. However, I plan to write an application that would help developers create their own custom templates once that functionality is enabled.

This project has a lot of improvements and with that comes a lot of testing and development time. Considering how I always manage to be busy, I suspect that a stable version may be released until sometime in 2024.

Top comments (0)