Last active
May 27, 2023 12:02
-
-
Save jazerix/f525cc7ce5ba154597cdf4ed823bb622 to your computer and use it in GitHub Desktop.
Latex Character count with spaces. Depends on the texcount library for Latex.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countLatex{ | |
param([string] $file) | |
$c = texcount .\$file.tex -char | select-string "Letters in text"; | |
$c = [int]$c.Line.substring(17); | |
$w = texcount .\$file.tex | select-string "Words in text"; | |
$w = [int]$w.Line.substring(15) | |
$total = $c + $w; | |
return $total; | |
} | |
function countLatexList{ | |
param([array] $texFiles) | |
$total = 0; | |
$counts = @(); | |
$texFiles | Foreach-Object { $total += $cur = countLatex($_); $counts+= $cur; } | |
for ($i = 0; $i -lt $texFiles.Length; $i++) | |
{ | |
$cur = $counts[$i]; | |
$percent = [math]::Round($cur / $total * 100, 2); | |
$text = $texFiles[$i] + ".tex: Characters (including space): $cur ($percent%)"; | |
echo $text; | |
} | |
echo "Total: $total" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment