From 139df8f7accf5716df1db8d44790bfe9bc186427 Mon Sep 17 00:00:00 2001 From: John Fox Date: Sun, 8 Sep 2024 20:28:25 -0400 Subject: [PATCH] tweak print.latexMatrix() to eliminate unnecessary empty \phantom{}s --- R/latexMatrix.R | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/R/latexMatrix.R b/R/latexMatrix.R index 543e20cc..42599484 100644 --- a/R/latexMatrix.R +++ b/R/latexMatrix.R @@ -753,10 +753,13 @@ print.latexMatrix <- function(x, onConsole=TRUE, countChars(colnames[j], adjust=FALSE) } pad <- max(max.col[j] - nchar, 0) - colnames[j] <- paste0(colnames[j], - paste0("\\phantom{", - paste(rep(colname.spacing, pad), collapse=""), - "}")) + if (any(pad > 0)){ + colnames[j] <- paste0(colnames[j], + paste0("\\phantom{", + paste(rep(colname.spacing, pad), + collapse=""), + "}")) + } } } if (!is.null(colnames)){