Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions crates/trios-phd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,61 @@ fn mechanical_latex_fixes(s: &str) -> String {
at_line_start = c == '\n';
i += 1;
}
// 4. Wrap every standalone `\begin{tabular}...\end{tabular}` in
// `\resizebox{\linewidth}{!}{...}` so wide tables never overflow
// the text width. Idempotent: skips tables already inside
// `\resizebox{\linewidth}{!}{` or `\adjustbox{`. Does NOT touch
// `tabular*`, `tabularx`, or `longtable` — those have their own
// width discipline.
out = wrap_wide_tabulars(&out);
out
}

/// Wrap each `\begin{tabular}{...}` ... `\end{tabular}` block in
/// `\resizebox{\linewidth}{!}{ ... }`. Idempotent.
fn wrap_wide_tabulars(s: &str) -> String {
let begin_tag = "\\begin{tabular}";
let end_tag = "\\end{tabular}";
let wrap_open = "\\resizebox{\\linewidth}{!}{%\n";
let wrap_close = "\n}";
let mut out = String::with_capacity(s.len() + 256);
let mut cursor = 0usize;
let bytes = s.as_bytes();
while let Some(rel) = s[cursor..].find(begin_tag) {
let abs = cursor + rel;
// Reject `\begin{tabular*}` and `\begin{tabularx}` — different envs.
let after = abs + begin_tag.len();
if after < bytes.len() && (bytes[after] == b'*' || bytes[after] == b'x') {
out.push_str(&s[cursor..after]);
cursor = after;
continue;
}
// Find matching `\end{tabular}`.
let Some(end_rel) = s[after..].find(end_tag) else {
out.push_str(&s[cursor..]);
return out;
};
let end_abs = after + end_rel + end_tag.len();
// Idempotency: if the ~80 chars before `\begin{tabular}` already
// contain `\resizebox{\linewidth}{!}{` with an open brace count >
// close brace count, this tabular is already wrapped.
let look_back_start = abs.saturating_sub(120);
let head = &s[look_back_start..abs];
let already_resized = head.contains("\\resizebox{\\linewidth}{!}{")
&& head.matches('{').count() > head.matches('}').count();
let already_adjust = head.contains("\\adjustbox{")
&& head.matches('{').count() > head.matches('}').count();
out.push_str(&s[cursor..abs]);
if already_resized || already_adjust {
out.push_str(&s[abs..end_abs]);
} else {
out.push_str(wrap_open);
out.push_str(&s[abs..end_abs]);
out.push_str(wrap_close);
}
cursor = end_abs;
}
out.push_str(&s[cursor..]);
out
}

Expand Down
4 changes: 2 additions & 2 deletions docs/phd/appendix/A-catalogue.tex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

\begin{figure}[H]
\centering
\includegraphics[width=0.92\textwidth,keepaspectratio]{app-a-cover-abstract.png}
\includegraphics[width=0.92\textwidth,keepaspectratio]{A-catalogue.jpg}
\caption{Abstract cover art for Appendix A.}
\label{fig:appA-cover}
\end{figure}
Expand Down Expand Up @@ -2286,7 +2286,7 @@ \section{42-Formula Summary (Original Catalogue)}

\begin{figure}[H]
\centering
\includegraphics[width=0.92\textwidth,keepaspectratio]{app-a-cover-abstract.png}
\includegraphics[width=0.92\textwidth,keepaspectratio]{A-catalogue.jpg}
\caption{Trinity Identity $\varphi^{2}+\varphi^{-2}=3$ --- algebraic anchor
for all 42 formulae.}
\label{fig:appA-42}
Expand Down
16 changes: 15 additions & 1 deletion docs/phd/appendix/B-falsification.tex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ \chapter*{Appendix B: Falsification Ledger — Popperian Audit Across 33 Chapter

\begin{figure}[H]
\centering
\includegraphics[width=0.92\textwidth,keepaspectratio]{app-b-golden-ledger.png}
\includegraphics[width=0.92\textwidth,keepaspectratio]{B-falsification.jpg}
\end{figure}

\addcontentsline{toc}{chapter}{Appendix B: Falsification Ledger}
Expand Down Expand Up @@ -153,6 +153,7 @@ \section*{B.3 — Bayesian Model Evidence Cross-Checks}
the monograph. Under Jeffreys' scale:

\begin{center}
\resizebox{\linewidth}{!}{%
\begin{tabular}{ll}
\hline
$\mathrm{BF}_{10}$ & Evidence for $H_1$ \\
Expand All @@ -164,6 +165,7 @@ \section*{B.3 — Bayesian Model Evidence Cross-Checks}
$>100$ & Decisive \\
\hline
\end{tabular}
}
\end{center}

\begin{description}
Expand Down Expand Up @@ -210,6 +212,7 @@ \subsection*{B.4.1 — Bonferroni Correction Across IGLA Seed Canon}
\noindent\textbf{Seed audit table:}

\begin{center}
\resizebox{\linewidth}{!}{%
\begin{tabular}{cccc}
\hline
Seed & Champion BPB & Baseline BPB & $p$-value (one-tailed) \\
Expand All @@ -220,6 +223,7 @@ \subsection*{B.4.1 — Bonferroni Correction Across IGLA Seed Canon}
123 & 2.2598 & 2.31 & $0.0093$ \\
\hline
\end{tabular}
}
\end{center}

\noindent All four per-seed $p$-values are $< 0.0125$. The Bonferroni-corrected
Expand Down Expand Up @@ -256,6 +260,7 @@ \section*{B.5 — Pre-Registration Manifest}
canonical URL for each chapter's pre-registered protocol.

\begin{center}
\resizebox{\linewidth}{!}{%
\begin{tabular}{clp{6cm}}
\hline
Chapter & Slug & Pre-registration URL \\
Expand Down Expand Up @@ -286,6 +291,7 @@ \section*{B.5 — Pre-Registration Manifest}
\texttt{https://osf.io/preprints/trinity-ch29} \\
\hline
\end{tabular}
}
\end{center}

\noindent The master pre-registration manifest (including version hashes of
Expand Down Expand Up @@ -853,6 +859,7 @@ \section*{B.10 — R5 Honesty Audit: Every Admitted Theorem}
referenced in the monograph.

\begin{center}
\resizebox{\linewidth}{!}{%
\begin{tabular}{p{3.5cm}p{4cm}p{4cm}c}
\hline
\textbf{Theorem / Lemma} & \textbf{Coq File} & \textbf{Reason Admitted} &
Expand All @@ -872,6 +879,7 @@ \section*{B.10 — R5 Honesty Audit: Every Admitted Theorem}
$\ln(9)/\ln(2)$ requires \texttt{Coq.Interval} & Partial \\
\hline
\end{tabular}
}
\end{center}

\noindent \textbf{``Blocks Claim?'' legend:}
Expand Down Expand Up @@ -1166,6 +1174,7 @@ \section*{B.15 — Summary Table: All Predictions}
% ============================================================

\begin{center}
\resizebox{\linewidth}{!}{%
\begin{tabular}{p{1.2cm}p{2cm}p{4cm}p{2.2cm}c}
\hline
\textbf{ID} & \textbf{Chapter} & \textbf{Prediction (brief)} &
Expand Down Expand Up @@ -1200,6 +1209,7 @@ \section*{B.15 — Summary Table: All Predictions}
\multicolumn{4}{l}{\textit{Total: 11 Standing, 4 Partially Falsified, 10 Pending, 0 Falsified}} & \\
\hline
\end{tabular}
}
\end{center}

% ============================================================
Expand Down Expand Up @@ -1303,6 +1313,7 @@ \section*{B.18 — Connection to Coq Falsification Witnesses}
\noindent The relevant falsification witnesses are:

\begin{center}
\resizebox{\linewidth}{!}{%
\begin{tabular}{lll}
\hline
\textbf{Coq File} & \textbf{Witness} & \textbf{What it demonstrates} \\
Expand All @@ -1321,6 +1332,7 @@ \section*{B.18 — Connection to Coq Falsification Witnesses}
$\sqrt{2}$ ratio does not match E8 spectrum \\
\hline
\end{tabular}
}
\end{center}

\noindent These witnesses are the machine-checkable counterparts of the
Expand Down Expand Up @@ -1517,6 +1529,7 @@ \section*{B.23 — IGLA Assertion Traceability (L-R14)}
L-R14 traces.

\begin{center}
\resizebox{\linewidth}{!}{%
\begin{tabular}{p{3cm}p{1.8cm}p{4.5cm}p{2cm}}
\hline
\textbf{Constant} & \textbf{Value} & \textbf{Derivation} & \textbf{Coq source} \\
Expand Down Expand Up @@ -1545,6 +1558,7 @@ \section*{B.23 — IGLA Assertion Traceability (L-R14)}
\texttt{gf16\_precision} \\
\hline
\end{tabular}
}
\end{center}

\noindent All constants marked with a $\varphi$-derivation are representable
Expand Down
Loading
Loading