{"record":{"id":"f3ee97c5597b7fab","repo":"docling-project/docling","slug":"the-pylatexenc-package-is-required-to-process-la","errorCode":null,"errorMessage":"The 'pylatexenc' package is required to process LaTeX files. Install it with `pip install 'docling-slim[format-latex]'`.","messagePattern":"The 'pylatexenc' package is required to process LaTeX files\\. Install it with `pip install 'docling-slim\\[format-latex\\]'`\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"docling/backend/latex/backend.py","lineNumber":66,"sourceCode":"    from docling.backend.latex.engines.tectonic import TectonicEngine\n\n\nclass LatexDocumentBackend(\n    DeclarativeDocumentBackend,\n    MacroHandlerMixin,\n    EnvironmentHandlerMixin,\n    MathHandlerMixin,\n    TextHelperMixin,\n    TableHelperMixin,\n):\n    def __init__(\n        self,\n        in_doc: InputDocument,\n        path_or_stream: Union[BytesIO, Path],\n        options: Optional[LatexBackendOptions] = None,\n    ):\n        if not _PYLATEXENC_AVAILABLE:\n            raise ImportError(_INSTALL_HINT) from _PYLATEXENC_IMPORT_ERROR\n        if options is None:\n            options = LatexBackendOptions()\n        super().__init__(in_doc, path_or_stream, options)\n        self.options = LatexBackendOptions.model_validate(self.options)\n        self.labels: dict[str, bool] = {}\n        self._custom_macros: dict[str, str] = {}\n        self._custom_macro_num_args: dict[str, int] = {}\n        self._input_stack: set[str] = set()\n        self._tectonic_engine: TectonicEngine | None = None\n        self._tikz_executor: concurrent.futures.ThreadPoolExecutor | None = None\n        self._tikz_futures: list[concurrent.futures.Future] = []\n        self.latex_text = decode_latex_content(self.path_or_stream)\n\n    def is_valid(self) -> bool:\n        text = self.latex_text.strip()\n        if not text:\n            return False\n        return True","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/backend/latex/backend.py#L48-L84","documentation":"LatexDocumentBackend.__init__ raises ImportError before super().__init__() when pylatexenc is not installed, chaining the original import error. LaTeX support is an optional extra in docling-slim; the message names the exact extra to install.","triggerScenarios":"Converting .tex files (InputFormat.LATEX) in an environment where docling-slim was installed without the format-latex extra, so `import pylatexenc` fails.","commonSituations":"Minimal deployment images; adding LaTeX conversion to an existing slim-based service without updating dependencies; lockfiles regenerated without the extra.","solutions":["Install the extra: pip install 'docling-slim[format-latex]'","Or install full docling","Add the extra to the deployment's dependency manifest so rebuilds keep it"],"exampleFix":"# before\npip install docling-slim\n\n# after\npip install 'docling-slim[format-latex]'","handlingStrategy":"validation","validationCode":"try:\n    import pylatexenc  # noqa: F401\nexcept ImportError:\n    raise RuntimeError(\"Install: pip install 'docling-slim[format-latex]'\")","typeGuard":null,"tryCatchPattern":"try:\n    result = converter.convert(src)\nexcept ImportError as exc:\n    if 'pylatexenc' in str(exc):\n        install_or_skip('docling-slim[format-latex]')\n    raise","preventionTips":["Add the format-latex extra wherever LaTeX conversion is enabled","Probe optional imports at startup for all accepted formats"],"tags":["latex","optional-dependency","installation","importerror"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}