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;
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
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.
add a comment |
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
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
add a comment |
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
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
input brackets
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.
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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”.
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,seddoesn't support non-greedy search strings.
– egreg
5 hours ago
add a comment |
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.

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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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”.
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,seddoesn't support non-greedy search strings.
– egreg
5 hours ago
add a comment |
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”.
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,seddoesn't support non-greedy search strings.
– egreg
5 hours ago
add a comment |
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”.
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”.
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,seddoesn't support non-greedy search strings.
– egreg
5 hours ago
add a comment |
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,seddoesn'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
add a comment |
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.

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
add a comment |
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.

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
add a comment |
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.

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
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.

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
edited 5 hours ago
answered 8 hours ago
MicoMico
296k32 gold badges410 silver badges808 bronze badges
296k32 gold badges410 silver badges808 bronze badges
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Welcome to TeX.SE. Are you open to using LuaLaTeX instead of pdfLaTeX?
– Mico
8 hours ago