Skip to content

Comments

[201_84]: Fix "Prefix by section number" not applying to Question/Answer#2845

Open
divyansharma001 wants to merge 1 commit intoMoganLab:mainfrom
divyansharma001:divyansharma001/201_84/fix_question_section_prefix
Open

[201_84]: Fix "Prefix by section number" not applying to Question/Answer#2845
divyansharma001 wants to merge 1 commit intoMoganLab:mainfrom
divyansharma001:divyansharma001/201_84/fix_question_section_prefix

Conversation

@divyansharma001
Copy link

Fixes #2806

Problem

The "Prefix by section number" style option works for Theorem and Proposition but not for Question and Answer.

Root Cause

In env-theorem.ts, Question and Answer were created with new-remark (adding them to theorem-env) and then individual-counter was called. However, individual-counter replaces display-question with the raw identity function, breaking the display chain:

After individual-counter, the chain becomes display-question → identity(nr), losing the section prefix entirely.

Fix

  • Created a new question-env counter group in env-base.ts as a sub-group of std-env with group-individual-counters (same pattern as exercise-env)
  • Added a new-question macro using question-env for counters and render-remark for rendering
  • Changed Question/Answer from new-remark + individual-counter to new-question

This preserves individual counters while maintaining the proper display chain for section prefixing.

How to Test

  1. Create a new document with article style
  2. Add chapters/sections with Question environments inside them
  3. Enable "Prefix by section number" in style options
  4. Verify Question/Answer numbers now show section prefix (e.g., "Question 1.1." instead of "Question 1.")
  5. Verify Theorem/Proposition still work correctly

Dev doc: devel/201_84.md

Create question-env counter group with group-individual-counters to
replace the broken individual-counter approach. Question and Answer
now route through the proper display chain for section prefixing while
keeping individual counters and remark rendering.

Fixes MoganLab#2806
Copilot AI review requested due to automatic review settings February 24, 2026 07:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where the "Prefix by section number" style option was not working for Question and Answer environments, while it worked correctly for other environments like Theorem and Proposition.

Changes:

  • Created a new question-env counter group following the same pattern as exercise-env, with individual counters and proper section prefix support
  • Added a new-question macro that uses the new counter group with render-remark for consistent visual styling
  • Replaced the problematic new-remark + individual-counter approach with the new new-question macro for Question and Answer environments

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
devel/201_84.md Dev documentation explaining the root cause and fix approach
TeXmacs/packages/environment/env-base.ts Added question-env counter group and new-question macro
TeXmacs/packages/environment/env-theorem.ts Changed Question/Answer to use new-question instead of new-remark + individual-counter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JackYansongLi JackYansongLi changed the title 201_84: Fix "Prefix by section number" not applying to Question/Answer [201_84]: Fix "Prefix by section number" not applying to Question/Answer Feb 25, 2026
@JackYansongLi
Copy link
Contributor

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prefix by section number 对 Question 不生效

2 participants