最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to handle The filename or extension is too long with a long pdflatex command - Stack Overflow

programmeradmin3浏览0评论

I have been assembling long command strings in order to pass large amounts of data into a latex project without having to stage the data first into a csv which slows down the process and can introduce other IO problems. Some of the datasets are much longer than others and I noticed that I was getting this message on just the long ones.

Program 'miktex-pdflatex.exe' failed to run: An error occurred trying to start process '.\miktex-pdflatex.exe' with working directory '.\'. The filename or extension is too long.At line:7 char:5

I did some testing and found that the limit is 32767 chars in the line. This seems to relate to 2^15 = 32768.

For example:

    $text = [string]::new('a', 32617)
    $state = $true
    do{
    try {
        ./miktex-pdflatex.exe -job-name="test" "\documentclass{report}\begin{document}$text\end{document}" -quiet
        Write-Progress -Activity "longer command" -Status $text.Length 
    }
    catch {
        Write-Warning ("Stopped at " + $text.Length)
        $state = $false
    }
    $text += "b"
    }while($state)

This char limit includes the fully resolved path of the exe and all of the flags in addition to the command text.

Is there another way introduce large amounts of data without csv files?

I have been assembling long command strings in order to pass large amounts of data into a latex project without having to stage the data first into a csv which slows down the process and can introduce other IO problems. Some of the datasets are much longer than others and I noticed that I was getting this message on just the long ones.

Program 'miktex-pdflatex.exe' failed to run: An error occurred trying to start process '.\miktex-pdflatex.exe' with working directory '.\'. The filename or extension is too long.At line:7 char:5

I did some testing and found that the limit is 32767 chars in the line. This seems to relate to 2^15 = 32768.

For example:

    $text = [string]::new('a', 32617)
    $state = $true
    do{
    try {
        ./miktex-pdflatex.exe -job-name="test" "\documentclass{report}\begin{document}$text\end{document}" -quiet
        Write-Progress -Activity "longer command" -Status $text.Length 
    }
    catch {
        Write-Warning ("Stopped at " + $text.Length)
        $state = $false
    }
    $text += "b"
    }while($state)

This char limit includes the fully resolved path of the exe and all of the flags in addition to the command text.

Is there another way introduce large amounts of data without csv files?

Share Improve this question edited Mar 11 at 13:07 Craig.C asked Mar 10 at 19:44 Craig.CCraig.C 6015 silver badges17 bronze badges 1
  • 1 Please improve code formatting to make this easier to answer – Mark Schultheiss Commented Mar 10 at 20:38
Add a comment  | 

1 Answer 1

Reset to default 0

I don't love this solution but it does work. If the text of the command isn't too long it is simply passed to pdflatex as part of the argument string. If it hits a threshold, then I divert the text to a tex file and reference that instead. This gives me a consistent way of avoiding csv files and limiting io.

$Table = ($DeptTransactions | ./Get-TransactionTable.ps1) -join ""
if($Table.Length -gt 30000){
    $TempTablePath = "$file`TempTable.tex"
    $Table > $TempTablePath
    $Table = "\input{$TempTablePath}"
}
发布评论

评论列表(0)

  1. 暂无评论