From 95bd42cea4c797f6e18c403c98a064a0c60849d9 Mon Sep 17 00:00:00 2001 From: Arseny <20096ninja@gmail.com> Date: Wed, 2 Sep 2026 13:16:18 +0300 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D1=80=D1=8B=20=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=BB=D0=B0=D0=B2=D0=B0=D1=8E=D1=89?= =?UTF-8?q?=D0=B8=D1=85=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=BE=D0=B2?= =?UTF-8?q?:=20=D0=BA=D1=80=D1=83=D0=BF=D0=BD=D1=8B=D0=B9=20=D1=80=D0=B8?= =?UTF-8?q?=D1=81=D1=83=D0=BD=D0=BE=D0=BA=20=D0=BE=D1=81=D1=82=D0=B0=D1=91?= =?UTF-8?q?=D1=82=D1=81=D1=8F=20=D0=BD=D0=B0=20=D1=81=D0=B2=D0=BE=D0=B5?= =?UTF-8?q?=D0=B9=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- md2gost/handlers/image.py | 2 +- md2gost/handlers/table.py | 2 +- md2gost/latex/preamble.py | 10 ++++++++++ tests/test_render.py | 6 +++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/md2gost/handlers/image.py b/md2gost/handlers/image.py index d845e80..44b8c16 100644 --- a/md2gost/handlers/image.py +++ b/md2gost/handlers/image.py @@ -96,7 +96,7 @@ def figure(tokens: list[Token]) -> str: caption = escape_latex(m.group(1)) lines = [ - "\\begin{figure}[ht]", + "\\begin{figure}[htb]", " \\centering", rf" \includegraphics[width={width}]{{\detokenize{{{path}}}}}", ] diff --git a/md2gost/handlers/table.py b/md2gost/handlers/table.py index 1a0f5ca..703f6f5 100644 --- a/md2gost/handlers/table.py +++ b/md2gost/handlers/table.py @@ -191,7 +191,7 @@ def captioned_table(tokens: list[Token]) -> str: return "\n".join( [ - "\\begin{table}[ht]", + "\\begin{table}[htb]", f" \\caption{{{caption}}}", " \\centering", _tabular(rows, aligns), diff --git a/md2gost/latex/preamble.py b/md2gost/latex/preamble.py index f07bb5d..33cd936 100644 --- a/md2gost/latex/preamble.py +++ b/md2gost/latex/preamble.py @@ -15,6 +15,16 @@ PREAMBLE = r"""\documentclass[a4paper, 14pt]{extarticle} \graphicspath{ {./} {./images/} } \usepackage{float} \usepackage[section]{placeins} +% Значения по умолчанию требуют, чтобы текст занимал не меньше 80 % страницы, +% а иллюстрация внизу — не больше 30 %. Из-за этого крупный рисунок не +% помещался на своей странице и уезжал, оставляя её наполовину пустой. +\renewcommand{\textfraction}{0.05} +\renewcommand{\topfraction}{0.95} +\renewcommand{\bottomfraction}{0.95} +\renewcommand{\floatpagefraction}{0.75} +\setcounter{topnumber}{3} +\setcounter{bottomnumber}{2} +\setcounter{totalnumber}{5} \usepackage{wrapfig} \sloppy \setlength{\emergencystretch}{2em} diff --git a/tests/test_render.py b/tests/test_render.py index d6107a0..ec527c1 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -48,7 +48,7 @@ def test_figure_with_caption(tmp_path) -> None: "![[images/antenna.png]]\n\nРисунок 1 — Антенна\n\n" "Данная антенна используется для ...\n" ) - assert "\\begin{figure}[ht]" in tex + assert "\\begin{figure}[htb]" in tex assert "\\centering" in tex assert ( "\\includegraphics[width=0.8\\textwidth]{\\detokenize{images/antenna.png}}" @@ -60,7 +60,7 @@ def test_figure_with_caption(tmp_path) -> None: def test_figure_without_caption() -> None: tex = render("![[images/photo.png]]\n\nОбычный абзац после картинки.\n") - assert "\\begin{figure}[ht]" in tex + assert "\\begin{figure}[htb]" in tex assert "\\caption{" not in tex assert "Обычный абзац после картинки." in tex @@ -127,7 +127,7 @@ TABLE_MD = ( def test_table_with_caption() -> None: tex = render(TABLE_MD) - assert "\\begin{table}[ht]" in tex + assert "\\begin{table}[htb]" in tex assert "\\caption{Сравнение скорости}" in tex assert "\\begin{tabularx}{\\textwidth}" in tex assert "\\textbf{1} & 0.027852 & 0.000285 \\\\" in tex