Skip to content

Commit a7cf41c

Browse files
committed
fix #11
1 parent 2aa0c1f commit a7cf41c

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 1.2.4 (2025-03-07)
2+
Support customizable spacing command in the `equation-src-format` field (default now is `"\\quad({num})"`). Also refer to issue #11.
3+
14
# 1.2.3 (2025-02-01)
25
Fix type casting problem when inputting the metadata from the command line.
36

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ By default, **if not specified**, the `Cref` format will be the capitalized vers
113113

114114
For sections, every level has its own formatting. You can set the metadata, for example, `section-src-format-1`, `section-cref-format-2`, etc.
115115

116+
For equations, the default `src` format (i.e. `equation-src-format`) is `"\\qquad({num})"`. `\qquad` is used to offer a little space between the equation and the number. You can customize it as you like.
117+
116118
#### Metadata Values
117119
The metadata values are python f-string format strings. Various fields are provided for you to customize the format. For example, if you set the `number-reset-level` to 2, `figure-prefix` to `figure` and `prefix-space` to `True`. Then, the fifth figure under subsection 2.3 will have the following fields:
118120
- `num`: `2.3.5`
@@ -292,7 +294,7 @@ table-src-format: "Table {h1}-{h2}-{tab_id}"
292294
table-cref-format: "table {tab_id} (in Section {h1}.{h2})"
293295
figure-src-format: "Figure {h1}.{h2}:{fig_id}"
294296
figure-cref-format: "as shown in Fig. {num}"
295-
equation-src-format: "({h1}-{h2}-{eq_id})"
297+
equation-src-format: "\\qquad({h1}-{h2}-{eq_id})"
296298
subfigure-src-format: "[{subfig_sym}({subfig_id})]"
297299
subfigure-symbols: "αβγδεζηθικλμνξοπρστυφχψω"
298300
custom-lot: true
@@ -354,4 +356,5 @@ There are some known issues and possible improvements:
354356
- [x] Add empty caption for figures and tables without captions (currently, they have no caption and therefore links to them cannot be located).
355357
- [ ] Directly support `align*` and other non-numbered environments.
356358
- [x] Subfigure support.
357-
- [x] Support short captions in `docx` output.
359+
- [x] Support short captions in `docx` output.
360+
- [ ] Support right-aligned equation numbers.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages = ["src/pandoc_tex_numbering"]
77

88
[project]
99
name = "pandoc-tex-numbering"
10-
version = "1.2.3"
10+
version = "1.2.4"
1111
dependencies = ["pylatexenc", "panflute"]
1212
requires-python = ">=3.8"
1313
authors = [{ name = "Chao Kong", email = "kongchao1998@gmail.com" }]

src/pandoc_tex_numbering/pandoc_tex_numbering.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def prepare(doc):
108108
["cref","{prefix}{num}"],
109109
["Cref",None]
110110
]:
111-
if item == "eq" and preset == "src": default = "({num})"
111+
if item == "eq" and preset == "src": default = "\\qquad({num})"
112112
fmt = doc.get_metadata(f"{aka[item]}-{preset}-format", default)
113113
fmt_presets[preset] = fmt
114114
formaters[item] = Formater(
@@ -251,7 +251,7 @@ def _parse_multiline_environment(root_node,doc):
251251
is_label_this_line = False
252252
if node.macroname == "\\":
253253
if is_label_this_line:
254-
environment_body += f"\\qquad{{{num_obj.src}}}"
254+
environment_body += f"{{{num_obj.src}}}"
255255
if label_of_this_line:
256256
labels[label_of_this_line] = num_obj
257257
doc.num_state.next_eq()
@@ -261,7 +261,7 @@ def _parse_multiline_environment(root_node,doc):
261261
environment_body += node.latex_verbatim()
262262

263263
if is_label_this_line:
264-
environment_body += f"\\qquad{{{num_obj.src}}}"
264+
environment_body += f"{{{num_obj.src}}}"
265265
if label_of_this_line:
266266
labels[label_of_this_line] = num_obj
267267
modified_math_str = f"\\begin{{{root_node.environmentname}}}{environment_body}\\end{{{root_node.environmentname}}}"
@@ -271,7 +271,7 @@ def _parse_plain_math(math_str:str,doc):
271271
labels = {}
272272
doc.num_state.next_eq()
273273
num_obj = doc.num_state.current_eq()
274-
modified_math_str = f"{math_str}\\qquad{{{num_obj.src}}}"
274+
modified_math_str = f"{math_str}{{{num_obj.src}}}"
275275
label_strings = re.findall(r"\\label\{(.*?)\}",math_str)
276276
if len(label_strings) >= 2:
277277
logger.warning(f"Multiple label_strings in one math block: {label_strings}")

tests/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ table-src-format: "Table {h1}-{h2}-{tab_id}"
1212
table-cref-format: "table {tab_id} (in Section {h1}.{h2})"
1313
figure-src-format: "Figure {h1}.{h2}:{fig_id}"
1414
figure-cref-format: "as shown in Fig. {num}"
15-
equation-src-format: "({h1}-{h2}-{eq_id})"
15+
equation-src-format: "\\qquad({h1}-{h2}-{eq_id})"
1616
subfigure-src-format: "[{subfig_sym}({subfig_id})]"
1717
subfigure-symbols: "αβγδεζηθικλμνξοπρστυφχψω"
1818
custom-lot: true

0 commit comments

Comments
 (0)