tonhowtf/omniget · error
nenhum .tex com \begin
Error message
nenhum .tex com \begin{{document}} What it means
The tar had at least one .tex file, but pick_main could not determine a main document — none of the .tex texts contains \begin{document}, which any compilable LaTeX root document must have. extract_source therefore fails with this message.
Solutions
- Extend pick_main to also recognize ConTeXt (\starttext) and plain TeX markers.
- Check the tar contents — maybe the root .tex has an unexpected name or extension and wasn't collected.
- Fall back to the largest .tex file as the main document when no \begin{document} is found.
- Skip such papers if compilable LaTeX is required.
Example fix
// before
let main_key = pick_main(&texts).ok_or_else(|| anyhow!("nenhum .tex com \\begin{{document}}"))?;
// after
let main_key = pick_main(&texts)
.or_else(|| texts.iter().max_by_key(|(_, t)| t.len()).map(|(k, _)| k.clone()))
.ok_or_else(|| anyhow!("nenhum .tex com \\begin{{document}}"))?; Defensive patterns
Strategy: fallback
Validate before calling
// heuristica propria antes da chamada:
fn parece_main(t: &str) -> bool {
t.contains("\\begin{document}") || t.contains("\\starttext")
} Try / catch
match extract_source(&bytes) {
Err(e) if e.to_string().contains("begin{document}") => {
// fallback: maior .tex como raiz
eprintln!("sem raiz LaTeX clara; usando maior .tex como main");
}
other => other,
} Prevention
- Extend main-document detection to ConTeXt (\starttext) and plain TeX bundles.
- Fall back to the largest .tex when no \begin{document} exists.
- Log candidate .tex filenames to diagnose why pick_main failed.
When it happens
Trigger: extract_source on a source bundle whose .tex files are all include/fragment files (no root), or files in non-LaTeX TeX dialects (plain TeX, ConTeXt) lacking \begin{document}.
Common situations: Plain TeX or ConTeXt submissions (different document markers); bundles where the root file uses a nonstandard class loaded via unusual preamble; fragmented multi-file papers whose root was excluded by the collector.
Related errors
- o source deste arXiv e um PDF, nao tem LaTeX
- source do arXiv nao parece LaTeX
- o tar do arXiv nao tem nenhum .tex
- download terminou mas nao achei o arquivo
- resposta do arXiv sem
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/27bd3f455a9e39d1.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/arxiv.rs:403
for entry in archive.entries()? {
let mut entry = entry?;
let path = entry.path()?.to_string_lossy().to_string();
let lower = path.to_lowercase();
if !(lower.ends_with(".tex") || lower.ends_with(".bbl") || lower.ends_with(".ltx")) {
continue;
}
let mut buf = Vec::new();
use std::io::Read;
entry.read_to_end(&mut buf)?;
names.push(path.clone());
texts.insert(path, String::from_utf8_lossy(&buf).to_string());
}
if texts.is_empty() {
return Err(anyhow!("o tar do arXiv nao tem nenhum .tex"));
}
let main_key =
pick_main(&texts).ok_or_else(|| anyhow!("nenhum .tex com \\begin{{document}}"))?;
let main = texts.get(&main_key).cloned().unwrap_or_default();
let main = resolve_inputs(&main, &texts, 0);
names.sort();
Ok(SourceBundle { main, files: names })
}
fn pick_main(texts: &HashMap<String, String>) -> Option<String> {
let mut best: Option<(u32, usize, String)> = None;
for (k, v) in texts {
if !k.to_lowercase().ends_with(".tex") && !k.to_lowercase().ends_with(".ltx") {
continue;
}
let mut score = 0u32;
if v.contains("\\begin{document}") {
score += 4;
}
if v.contains("\\documentclass") {
score += 2;View on GitHub (pinned to 8600b91f42)