WeaveBench / tasks /DOC /DOC_task_1_latex_figure_overflow.md
wanlilll's picture
Add 114 tasks under 8-domain flat layout
71e9dba verified
metadata
id: DOC_task_1_latex_figure_overflow
name:  LaTeX figure 出血 + 浮动错位 (TeXstudio + pdflatex)
category: DOC
timeout_seconds: 1500

Prompt

/tmp_workspace/paper.tex compiles successfully, but the rendered PDF has two problems that can only be detected by visual inspection:

  1. Figure 1 visually overflows the right margin — the included image width is set incorrectly.
  2. Figure 1 ends up on the wrong page — the Discussion section says "Figure 1 shows ...", but the Figure 1: caption is actually rendered on an earlier page (because the figure float [t] places too eagerly and pushes the body text down).

Task: Modify /tmp_workspace/paper.tex (this file only) so that (a) the figure no longer overflows the right margin; (b) the figure lands on the same page as the Discussion sentence "Figure 1 shows ...".

Deliverables (write to /tmp_workspace/results/):

  • paper.pdf — the PDF re-compiled after the fix.
  • proof.png — a proof screenshot showing the figure and the "Figure 1 shows ..." paragraph on the same page, with the figure no longer overflowing the right margin.
  • report.md, which must contain:
    • width_token: <whatever you ended up writing for width=>
    • same_page: yes
    • tool_used: <name>
    • A description of at least 30 characters explaining the visual difference between the PDF before and after the fix.

Expected Behavior

参考解题流程 (设计者参考, 不发给 agent):

  1. cd /tmp_workspace && pdflatex -interaction=nonstopmode paper.tex → 第一份有问题的 PDF。
  2. 看 PDF 确认 figure 出血 + figure 在错的页。
  3. 编辑 paper.tex(只改这一个文件):
    • \includegraphics 的宽度调到不再溢出右边距。
    • 让 figure 与 Discussion 的 "Figure 1 shows ..." 落到同一页(自行决定如何调整 figure 的浮动放置或位置)。
  4. 重新编译 → 看 PDF 确认两处都修好。
  5. cp /tmp_workspace/paper.pdf /tmp_workspace/results/paper.pdf
  6. 截一张能看到 figure 与 "Figure 1 shows ..." 段落同一页的截图保存为 /tmp_workspace/results/proof.png
  7. /tmp_workspace/results/report.mdwidth_token / same_page: yes / tool_used / 一段 ≥ 30 字符说明。

判分要点速览:

  1. pdflatex paper.tex → 第一份有问题的 PDF。
  2. 看 PDF 确认 figure 出血 + figure 在错的页。
  3. 改 paper.tex (width + 浮动)。
  4. 重新编译。
  5. cp → results/paper.pdf, 截图 → proof.png, 写 report.md。

Source

  • EyesOn-Bench Seed v12 DOC-02 改编

Grading Criteria

    1. results/paper.pdf 存在 (会 rebuild verify)
    1. paper.tex 中 \includegraphics 的 width <= \textwidth (即不再溢出)
    1. (rebuilt PDF) 'Figure 1:' caption 与 'Figure 1 shows' 在同一页
    1. report.md 存在 + width_token + same_page + tool_used + 解释段
    1. proof.png 存在 >= 5 KB
    1. (VLM HARD GATE) proof.png 看得出 figure 与提及它的段落在同一页

Automated Checks

def grade(workspace_path=None, **kwargs) -> dict:
    import re, subprocess
    from pathlib import Path
    try:
        from PIL import Image
    except Exception:
        Image = None
    try:
        from _judge_helper import vlm_score_rubric
    except Exception:
        vlm_score_rubric = None

    rd = Path("/tmp_workspace/results")
    ws = Path("/tmp_workspace")
    scores = {}

    rep = rd / "report.md"
    text = rep.read_text(encoding="utf-8", errors="ignore") if rep.exists() else ""
    scores["report_exists"] = 1.0 if text.strip() else 0.0

    # 1. results/paper.pdf exists
    pdf = rd / "paper.pdf"
    scores["pdf_exists"] = 1.0 if (pdf.exists() and pdf.stat().st_size >= 5 * 1024) else 0.0

    # 2. width fix in tex
    tex = ws / "paper.tex"
    scores["width_fixed"] = 0.0
    if tex.exists():
        t = tex.read_text(encoding="utf-8", errors="ignore")
        m = re.search(r"\\includegraphics\[[^]]*width\s*=\s*([0-9.]+)\\textwidth", t)
        if m:
            w = float(m.group(1))
            scores["width_value"] = w
            if w <= 1.0:
                scores["width_fixed"] = 1.0

    # 3. same-page check via pdftotext -layout
    scores["same_page"] = 0.0
    if pdf.exists():
        try:
            out = subprocess.run(
                ["pdftotext", "-layout", str(pdf), "-"],
                capture_output=True, text=True, timeout=30).stdout
            # split per page (pdftotext separates with form feed \f)
            pages = out.split("\f")
            for pg in pages:
                if ("Figure 1:" in pg or "Figure\u00a01:" in pg) and \
                   ("Figure 1 shows" in pg or "Figure~1 shows" in pg or "Figure\u00a01 shows" in pg):
                    scores["same_page"] = 1.0
                    break
        except Exception as e:
            scores["pdftotext_err"] = str(e)[:100]

    # 4. report fields
    scores["width_field"] = 1.0 if re.search(r"width_token\s*[:=]\s*\S+", text) else 0.0
    sp_m = re.search(r"same_page\s*[:=]\s*(yes|no)", text, re.IGNORECASE)
    scores["same_page_field_yes"] = 1.0 if (sp_m and sp_m.group(1).lower() == "yes") else 0.0
    scores["tool_field"] = 1.0 if re.search(r"tool_used\s*[:=]\s*\S+", text) else 0.0
    explain = "\n".join(
        ln for ln in text.splitlines()
        if not re.match(r"\s*(width_token|same_page|tool_used)\s*[:=]", ln, re.IGNORECASE)
    ).strip()
    scores["explanation_len"] = 1.0 if len(explain) >= 30 else (len(explain) / 30.0)

    # 5. proof.png — must be a real screenshot, not a tiny placeholder
    pp = rd / "proof.png"
    pp_size = pp.stat().st_size if pp.exists() else 0
    scores["proof_png"] = 1.0 if (pp.exists() and pp_size >= 20 * 1024) else (
        0.4 if (pp.exists() and pp_size >= 5 * 1024) else 0.0
    )
    scores["proof_png_size"] = pp_size
    # resolution gate: real desktop screenshot should be >= 1024x600
    scores["proof_png_resolution"] = 0.0
    if pp.exists() and Image is not None:
        try:
            with Image.open(pp) as im:
                w, h = im.size
                scores["proof_png_w"] = w
                scores["proof_png_h"] = h
                if w >= 1024 and h >= 600:
                    scores["proof_png_resolution"] = 1.0
                elif w >= 800 and h >= 480:
                    scores["proof_png_resolution"] = 0.5
        except Exception:
            pass

    # 加权分组:core 60% / gui 30% / aux 10%
    core = (
        0.45 * scores["width_fixed"] +
        0.45 * scores["same_page"] +
        0.10 * scores["pdf_exists"]
    )
    gui = (
        0.55 * scores["proof_png"] +
        0.45 * scores["proof_png_resolution"]
    )
    aux = (
        0.20 * scores["report_exists"] +
        0.20 * scores["width_field"] +
        0.20 * scores["same_page_field_yes"] +
        0.20 * scores["tool_field"] +
        0.20 * scores["explanation_len"]
    )
    base = 0.6 * core + 0.3 * gui + 0.1 * aux
    scores["core"] = round(core, 3)
    scores["gui"] = round(gui, 3)
    scores["aux"] = round(aux, 3)
    scores["overall_score"] = round(base, 3)

    # Structural hard gates (无 VLM 也必须卡住退化路径)
    if scores.get("width_fixed", 0.0) < 0.5 or scores.get("same_page", 0.0) < 0.5:
        scores["overall_score"] = min(scores["overall_score"], 0.4)
        base = min(base, 0.4)
    if scores.get("proof_png", 0.0) < 0.5 or scores.get("proof_png_resolution", 0.0) < 0.5:
        scores["overall_score"] = min(scores["overall_score"], 0.5)
        base = min(base, 0.5)

    # 6. VLM HARD GATE
    if vlm_score_rubric and pp.exists() and pp_size >= 20 * 1024:
        rubric = {
            "vlm_pdf_view":           "proof.png 是 PDF 阅读器 (TeXstudio 预览面板 / Okular / Evince) 或 pdftoppm 渲染的 PDF 页面截图;不是空白图、终端文本、源代码窗口。",
            "vlm_figure_visible":     "proof.png 中能直接看到一张柱状图 (Q3 throughput 直方图) + 它的 caption 'Figure 1: Sustained throughput ...'。",
            "vlm_reference_visible":  "proof.png 同一张图里能直接看到正文 'Figure 1 shows' 那段话 — 即图与引用它的段落同时出现在画面里。",
            "vlm_no_overflow":        "proof.png 中那张图没有明显冲出右边距 (没有图被裁/超出页面边界)。",
        }
        try:
            vlm = vlm_score_rubric([str(pp)], rubric,
                instruction="判断 PDF 截图里 figure 是否与 'Figure 1 shows' 段落同页且不出血。")
            for k in rubric: scores[k] = vlm.get(k, 0.0)
            scores["judge_method"] = vlm.get("judge_method", "failed")
            vlm_avg = sum(vlm.get(k, 0.0) for k in rubric) / len(rubric)
            scores["vlm_avg"] = round(vlm_avg, 3)
            # VLM 占 50%;同时再次卡硬阈值
            scores["overall_score"] = round(0.5*base + 0.5*vlm_avg, 3)
            # HARD GATES (上拉)
            if scores.get("vlm_pdf_view", 0.0) < 0.7:
                scores["overall_score"] = min(scores["overall_score"], 0.25)
            if scores.get("vlm_reference_visible", 0.0) < 0.7:
                scores["overall_score"] = min(scores["overall_score"], 0.45)
            if scores.get("vlm_figure_visible", 0.0) < 0.6:
                scores["overall_score"] = min(scores["overall_score"], 0.45)
            if scores.get("vlm_no_overflow", 0.0) < 0.5:
                scores["overall_score"] = min(scores["overall_score"], 0.55)
            if vlm_avg < 0.4:
                scores["overall_score"] = min(scores["overall_score"], 0.30)
        except Exception:
            pass
    else:
        # VLM 不可用 → 封顶 0.6,避免无视觉证据也满分
        scores["judge_method"] = "vlm_unavailable"
        scores["overall_score"] = min(scores["overall_score"], 0.6)
    return scores

Workspace Path

workspace/DOC/task_1_latex_figure_overflow

Skills


Env


Warmup

mkdir -p /tmp_workspace/results || true
which pdflatex >/dev/null 2>&1 || apt-get install -y -qq --no-install-recommends texlive-latex-base texlive-latex-recommended texlive-fonts-recommended texlive-latex-extra || true
which pdftotext >/dev/null 2>&1 || apt-get install -y -qq poppler-utils || true
bash /tmp_workspace/make_plot.sh || true
chown -R user:user /tmp_workspace || true
rm -f /home/user/.openclaw/agents/main/sessions/*.lock 2>/dev/null || true
openclaw config unset agents.defaults.imageModel >/dev/null 2>&1 || true
openclaw config set agents.defaults.sandbox.imageModel.primary "" >/dev/null 2>&1 || true