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

I have been assembling long command strings in order to pass large amounts of data into a latex project

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}"
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744826365a4595821.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信