Combining latex input and sedStore and retrieve content across documentsHow can I use input and include with biblatex (biber backend)?Fit tables read in with input to page-widthLatex (XeTex) places equation parenthesis the wrong wayHow to input text from a fileLaTeX input from subfolders and subsubfoldersdisplay/print input filename at top of each page in draft modeHowto add batch section and input in a Latex documentUsing input to insert Tikz-code from another file: nested input cause wider border each time called?change the default path where Latex looks for everything

As the Dungeon Master, how do I handle a player that insists on a specific class when I already know that choice will cause issues?

Shortest hex dumping program

Graduate student with abysmal English writing skills, how to help

Why doesn't sea level show seasonality?

What is a solution?

Has anyone in space seen or photographed a simple laser pointer from Earth?

Received a dinner invitation through my employer's email, is it ok to attend?

How did the hit man miss?

Did the Vulgar Latin verb "toccare" exist?

Confirming the Identity of a (Friendly) Reviewer After the Reviews

Why are all my yellow 2V/20mA LEDs burning out with 330k Ohm resistor?

Integer Lists of Noah

Optimization terminology: "Exact" v. "Approximate"

How to ask for a LinkedIn endorsement?

Cops: The Hidden OEIS Substring

Do I have a right to cancel a purchase of foreign currency in the UK?

Is the genetic term "polycistronic" still used in modern biology?

Cracking the Coding Interview — 1.5 One Away

Keep milk (or milk alternative) for a day without a fridge

Storming Area 51

Does throwing a penny at a train stop the train?

How can I effectively communicate to recruiters that a phone call is not possible?

Why did Harry Potter get a bedroom?

Why didn't Nick Fury expose the villain's identity and plans?



Combining latex input and sed


Store and retrieve content across documentsHow can I use input and include with biblatex (biber backend)?Fit tables read in with input to page-widthLatex (XeTex) places equation parenthesis the wrong wayHow to input text from a fileLaTeX input from subfolders and subsubfoldersdisplay/print input filename at top of each page in draft modeHowto add batch section and input in a Latex documentUsing input to insert Tikz-code from another file: nested input cause wider border each time called?change the default path where Latex looks for everything






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















I need to include file, but I want to manipulate it directly from PDFLaTeX.
I must remove any text which is betweem and , including backslashes and parenthesis. I have tried many escaping options, but the best I could get it this and it is not working:



input


Is this possible at all?










share|improve this question







New contributor



meolic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Welcome to TeX.SE. Are you open to using LuaLaTeX instead of pdfLaTeX?

    – Mico
    8 hours ago

















4















I need to include file, but I want to manipulate it directly from PDFLaTeX.
I must remove any text which is betweem and , including backslashes and parenthesis. I have tried many escaping options, but the best I could get it this and it is not working:



input


Is this possible at all?










share|improve this question







New contributor



meolic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Welcome to TeX.SE. Are you open to using LuaLaTeX instead of pdfLaTeX?

    – Mico
    8 hours ago













4












4








4


1






I need to include file, but I want to manipulate it directly from PDFLaTeX.
I must remove any text which is betweem and , including backslashes and parenthesis. I have tried many escaping options, but the best I could get it this and it is not working:



input


Is this possible at all?










share|improve this question







New contributor



meolic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I need to include file, but I want to manipulate it directly from PDFLaTeX.
I must remove any text which is betweem and , including backslashes and parenthesis. I have tried many escaping options, but the best I could get it this and it is not working:



input


Is this possible at all?







input brackets






share|improve this question







New contributor



meolic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question







New contributor



meolic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question






New contributor



meolic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 8 hours ago









meolicmeolic

1212 bronze badges




1212 bronze badges




New contributor



meolic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




meolic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • Welcome to TeX.SE. Are you open to using LuaLaTeX instead of pdfLaTeX?

    – Mico
    8 hours ago

















  • Welcome to TeX.SE. Are you open to using LuaLaTeX instead of pdfLaTeX?

    – Mico
    8 hours ago
















Welcome to TeX.SE. Are you open to using LuaLaTeX instead of pdfLaTeX?

– Mico
8 hours ago





Welcome to TeX.SE. Are you open to using LuaLaTeX instead of pdfLaTeX?

– Mico
8 hours ago










2 Answers
2






active

oldest

votes


















5














This works for me (with pdflatex -shell-escape, of course) and prints just “abc”.



beginfilecontents*jobname-test.tex
abcdef
endfilecontents*

documentclassarticle

begindocument

input

enddocument


The issue is that TeX performs macro expansion on the argument to input; with string\ we nullify the macro nature of \.



I use jobname just for avoiding the risk of clobbering my files.



If you want a non-greedy replacement, it's a bit more complicated (you could use Perl, instead). The search string should be something like



\[^\]*\}


This can be more easily accomplished by defining the string beforehand:



beginfilecontents*jobname-test.tex
abcdefghijkl
endfilecontents*

documentclassarticle

begindocument

edefsearchstringstring\string[^string\string]*string\string}
input

enddocument


In this case the output would by “abcghi”.






share|improve this answer




















  • 1





    +1 :) just wondered if the match might be .*? so as to be non-greedy?

    – cmhughes
    5 hours ago











  • @cmhughes As far as I know, sed doesn't support non-greedy search strings.

    – egreg
    5 hours ago


















4














Assuming you're free to use LuaLaTeX, and assuming further that the material between and (including the delimiters) is all on one line, the following solution should work just fine for you.



The solution consists of a Lua function (stored in an external file) and two LaTeX macros; the first assigns the Lua function to the process_input_buffer callback, making it act like a preprocessor, and the second removes the preprocessor-like operation of the Lua function.



enter image description here



The pattern-matching operation, "\.-\", uses .- rather than -* to match "zero or more instances of any character". Observe that using -* would be a mistake here, as it would make Lua perform a "greedy" match and thus inappropriately obliterate the middle substring, uvw.



RequirePackagefilecontents
%% External file with " ... " material
beginfilecontents*cxf.tex
$abc ... uvw int_0^1 xyz$

abc ... uvw int_0^1 xyz
endfilecontents*

% Place the Lua code in a separate external file
beginfilecontents*external.lua
function remove_braced_stuff ( s )
return ( s:gsub ( "\.-\" , "" ) )
end
endfilecontents*

documentclassarticle
%% Load the Lua function from the external file
directluadofile("external.lua")

%% Two utility LaTeX macros
newcommandRemoveBracedStuffdirectlua
luatexbase.add_to_callback ( "process_input_buffer" ,
remove_braced_stuff , "removestuff" )
newcommandDontRemoveBracedStuffdirectlua
luatexbase.remove_from_callback ( "process_input_buffer" ,
"removestuff" )

begindocument
RemoveBracedStuff % Enable the Lua function
input cxf % Load the external file

DontRemoveBracedStuff % Disable the Lua function
%% remainder of document
enddocument





share|improve this answer



























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "85"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    meolic is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f499387%2fcombining-latex-input-and-sed%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5














    This works for me (with pdflatex -shell-escape, of course) and prints just “abc”.



    beginfilecontents*jobname-test.tex
    abcdef
    endfilecontents*

    documentclassarticle

    begindocument

    input

    enddocument


    The issue is that TeX performs macro expansion on the argument to input; with string\ we nullify the macro nature of \.



    I use jobname just for avoiding the risk of clobbering my files.



    If you want a non-greedy replacement, it's a bit more complicated (you could use Perl, instead). The search string should be something like



    \[^\]*\}


    This can be more easily accomplished by defining the string beforehand:



    beginfilecontents*jobname-test.tex
    abcdefghijkl
    endfilecontents*

    documentclassarticle

    begindocument

    edefsearchstringstring\string[^string\string]*string\string}
    input

    enddocument


    In this case the output would by “abcghi”.






    share|improve this answer




















    • 1





      +1 :) just wondered if the match might be .*? so as to be non-greedy?

      – cmhughes
      5 hours ago











    • @cmhughes As far as I know, sed doesn't support non-greedy search strings.

      – egreg
      5 hours ago















    5














    This works for me (with pdflatex -shell-escape, of course) and prints just “abc”.



    beginfilecontents*jobname-test.tex
    abcdef
    endfilecontents*

    documentclassarticle

    begindocument

    input

    enddocument


    The issue is that TeX performs macro expansion on the argument to input; with string\ we nullify the macro nature of \.



    I use jobname just for avoiding the risk of clobbering my files.



    If you want a non-greedy replacement, it's a bit more complicated (you could use Perl, instead). The search string should be something like



    \[^\]*\}


    This can be more easily accomplished by defining the string beforehand:



    beginfilecontents*jobname-test.tex
    abcdefghijkl
    endfilecontents*

    documentclassarticle

    begindocument

    edefsearchstringstring\string[^string\string]*string\string}
    input

    enddocument


    In this case the output would by “abcghi”.






    share|improve this answer




















    • 1





      +1 :) just wondered if the match might be .*? so as to be non-greedy?

      – cmhughes
      5 hours ago











    • @cmhughes As far as I know, sed doesn't support non-greedy search strings.

      – egreg
      5 hours ago













    5












    5








    5







    This works for me (with pdflatex -shell-escape, of course) and prints just “abc”.



    beginfilecontents*jobname-test.tex
    abcdef
    endfilecontents*

    documentclassarticle

    begindocument

    input

    enddocument


    The issue is that TeX performs macro expansion on the argument to input; with string\ we nullify the macro nature of \.



    I use jobname just for avoiding the risk of clobbering my files.



    If you want a non-greedy replacement, it's a bit more complicated (you could use Perl, instead). The search string should be something like



    \[^\]*\}


    This can be more easily accomplished by defining the string beforehand:



    beginfilecontents*jobname-test.tex
    abcdefghijkl
    endfilecontents*

    documentclassarticle

    begindocument

    edefsearchstringstring\string[^string\string]*string\string}
    input

    enddocument


    In this case the output would by “abcghi”.






    share|improve this answer















    This works for me (with pdflatex -shell-escape, of course) and prints just “abc”.



    beginfilecontents*jobname-test.tex
    abcdef
    endfilecontents*

    documentclassarticle

    begindocument

    input

    enddocument


    The issue is that TeX performs macro expansion on the argument to input; with string\ we nullify the macro nature of \.



    I use jobname just for avoiding the risk of clobbering my files.



    If you want a non-greedy replacement, it's a bit more complicated (you could use Perl, instead). The search string should be something like



    \[^\]*\}


    This can be more easily accomplished by defining the string beforehand:



    beginfilecontents*jobname-test.tex
    abcdefghijkl
    endfilecontents*

    documentclassarticle

    begindocument

    edefsearchstringstring\string[^string\string]*string\string}
    input

    enddocument


    In this case the output would by “abcghi”.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 5 hours ago

























    answered 8 hours ago









    egregegreg

    754k90 gold badges1977 silver badges3316 bronze badges




    754k90 gold badges1977 silver badges3316 bronze badges







    • 1





      +1 :) just wondered if the match might be .*? so as to be non-greedy?

      – cmhughes
      5 hours ago











    • @cmhughes As far as I know, sed doesn't support non-greedy search strings.

      – egreg
      5 hours ago












    • 1





      +1 :) just wondered if the match might be .*? so as to be non-greedy?

      – cmhughes
      5 hours ago











    • @cmhughes As far as I know, sed doesn't support non-greedy search strings.

      – egreg
      5 hours ago







    1




    1





    +1 :) just wondered if the match might be .*? so as to be non-greedy?

    – cmhughes
    5 hours ago





    +1 :) just wondered if the match might be .*? so as to be non-greedy?

    – cmhughes
    5 hours ago













    @cmhughes As far as I know, sed doesn't support non-greedy search strings.

    – egreg
    5 hours ago





    @cmhughes As far as I know, sed doesn't support non-greedy search strings.

    – egreg
    5 hours ago













    4














    Assuming you're free to use LuaLaTeX, and assuming further that the material between and (including the delimiters) is all on one line, the following solution should work just fine for you.



    The solution consists of a Lua function (stored in an external file) and two LaTeX macros; the first assigns the Lua function to the process_input_buffer callback, making it act like a preprocessor, and the second removes the preprocessor-like operation of the Lua function.



    enter image description here



    The pattern-matching operation, "\.-\", uses .- rather than -* to match "zero or more instances of any character". Observe that using -* would be a mistake here, as it would make Lua perform a "greedy" match and thus inappropriately obliterate the middle substring, uvw.



    RequirePackagefilecontents
    %% External file with " ... " material
    beginfilecontents*cxf.tex
    $abc ... uvw int_0^1 xyz$

    abc ... uvw int_0^1 xyz
    endfilecontents*

    % Place the Lua code in a separate external file
    beginfilecontents*external.lua
    function remove_braced_stuff ( s )
    return ( s:gsub ( "\.-\" , "" ) )
    end
    endfilecontents*

    documentclassarticle
    %% Load the Lua function from the external file
    directluadofile("external.lua")

    %% Two utility LaTeX macros
    newcommandRemoveBracedStuffdirectlua
    luatexbase.add_to_callback ( "process_input_buffer" ,
    remove_braced_stuff , "removestuff" )
    newcommandDontRemoveBracedStuffdirectlua
    luatexbase.remove_from_callback ( "process_input_buffer" ,
    "removestuff" )

    begindocument
    RemoveBracedStuff % Enable the Lua function
    input cxf % Load the external file

    DontRemoveBracedStuff % Disable the Lua function
    %% remainder of document
    enddocument





    share|improve this answer





























      4














      Assuming you're free to use LuaLaTeX, and assuming further that the material between and (including the delimiters) is all on one line, the following solution should work just fine for you.



      The solution consists of a Lua function (stored in an external file) and two LaTeX macros; the first assigns the Lua function to the process_input_buffer callback, making it act like a preprocessor, and the second removes the preprocessor-like operation of the Lua function.



      enter image description here



      The pattern-matching operation, "\.-\", uses .- rather than -* to match "zero or more instances of any character". Observe that using -* would be a mistake here, as it would make Lua perform a "greedy" match and thus inappropriately obliterate the middle substring, uvw.



      RequirePackagefilecontents
      %% External file with " ... " material
      beginfilecontents*cxf.tex
      $abc ... uvw int_0^1 xyz$

      abc ... uvw int_0^1 xyz
      endfilecontents*

      % Place the Lua code in a separate external file
      beginfilecontents*external.lua
      function remove_braced_stuff ( s )
      return ( s:gsub ( "\.-\" , "" ) )
      end
      endfilecontents*

      documentclassarticle
      %% Load the Lua function from the external file
      directluadofile("external.lua")

      %% Two utility LaTeX macros
      newcommandRemoveBracedStuffdirectlua
      luatexbase.add_to_callback ( "process_input_buffer" ,
      remove_braced_stuff , "removestuff" )
      newcommandDontRemoveBracedStuffdirectlua
      luatexbase.remove_from_callback ( "process_input_buffer" ,
      "removestuff" )

      begindocument
      RemoveBracedStuff % Enable the Lua function
      input cxf % Load the external file

      DontRemoveBracedStuff % Disable the Lua function
      %% remainder of document
      enddocument





      share|improve this answer



























        4












        4








        4







        Assuming you're free to use LuaLaTeX, and assuming further that the material between and (including the delimiters) is all on one line, the following solution should work just fine for you.



        The solution consists of a Lua function (stored in an external file) and two LaTeX macros; the first assigns the Lua function to the process_input_buffer callback, making it act like a preprocessor, and the second removes the preprocessor-like operation of the Lua function.



        enter image description here



        The pattern-matching operation, "\.-\", uses .- rather than -* to match "zero or more instances of any character". Observe that using -* would be a mistake here, as it would make Lua perform a "greedy" match and thus inappropriately obliterate the middle substring, uvw.



        RequirePackagefilecontents
        %% External file with " ... " material
        beginfilecontents*cxf.tex
        $abc ... uvw int_0^1 xyz$

        abc ... uvw int_0^1 xyz
        endfilecontents*

        % Place the Lua code in a separate external file
        beginfilecontents*external.lua
        function remove_braced_stuff ( s )
        return ( s:gsub ( "\.-\" , "" ) )
        end
        endfilecontents*

        documentclassarticle
        %% Load the Lua function from the external file
        directluadofile("external.lua")

        %% Two utility LaTeX macros
        newcommandRemoveBracedStuffdirectlua
        luatexbase.add_to_callback ( "process_input_buffer" ,
        remove_braced_stuff , "removestuff" )
        newcommandDontRemoveBracedStuffdirectlua
        luatexbase.remove_from_callback ( "process_input_buffer" ,
        "removestuff" )

        begindocument
        RemoveBracedStuff % Enable the Lua function
        input cxf % Load the external file

        DontRemoveBracedStuff % Disable the Lua function
        %% remainder of document
        enddocument





        share|improve this answer















        Assuming you're free to use LuaLaTeX, and assuming further that the material between and (including the delimiters) is all on one line, the following solution should work just fine for you.



        The solution consists of a Lua function (stored in an external file) and two LaTeX macros; the first assigns the Lua function to the process_input_buffer callback, making it act like a preprocessor, and the second removes the preprocessor-like operation of the Lua function.



        enter image description here



        The pattern-matching operation, "\.-\", uses .- rather than -* to match "zero or more instances of any character". Observe that using -* would be a mistake here, as it would make Lua perform a "greedy" match and thus inappropriately obliterate the middle substring, uvw.



        RequirePackagefilecontents
        %% External file with " ... " material
        beginfilecontents*cxf.tex
        $abc ... uvw int_0^1 xyz$

        abc ... uvw int_0^1 xyz
        endfilecontents*

        % Place the Lua code in a separate external file
        beginfilecontents*external.lua
        function remove_braced_stuff ( s )
        return ( s:gsub ( "\.-\" , "" ) )
        end
        endfilecontents*

        documentclassarticle
        %% Load the Lua function from the external file
        directluadofile("external.lua")

        %% Two utility LaTeX macros
        newcommandRemoveBracedStuffdirectlua
        luatexbase.add_to_callback ( "process_input_buffer" ,
        remove_braced_stuff , "removestuff" )
        newcommandDontRemoveBracedStuffdirectlua
        luatexbase.remove_from_callback ( "process_input_buffer" ,
        "removestuff" )

        begindocument
        RemoveBracedStuff % Enable the Lua function
        input cxf % Load the external file

        DontRemoveBracedStuff % Disable the Lua function
        %% remainder of document
        enddocument






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 5 hours ago

























        answered 8 hours ago









        MicoMico

        296k32 gold badges410 silver badges808 bronze badges




        296k32 gold badges410 silver badges808 bronze badges




















            meolic is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            meolic is a new contributor. Be nice, and check out our Code of Conduct.












            meolic is a new contributor. Be nice, and check out our Code of Conduct.











            meolic is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f499387%2fcombining-latex-input-and-sed%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

            Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

            François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480