This is a very, very basic question, yet all the solutions I found so
far are somewhat unsatisfying.
I would like to define an alias, which I would afterward use like:
"The mechanism \ref{flow_topography_interaction} is the most effective
one when..."
with \ref{flow_topography_interaction} being replaced by another
string I defined earlier.
The answer I see everywhere is to "define a new command" as in:
\newcommand{\mycommand}{whatever I want}
But I do not find this terribly satisfying because underscores,
numbers and hyphens are not allowed within the name of commands. I can
hardly believe that there isn't a simpler and more elegant way in
LaTeX than to define a new function?
Thanks for any help..
--
You received this message because you are subscribed to the Google Groups "LaTeX Users Group" group.
To post to this group, send email to latexus...@googlegroups.com.
To unsubscribe from this group, send email to latexusersgro...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/latexusersgroup?hl=en.
> %defining a box variable
> \newsavebox{\my_text}
then LaTeX will struggle on the underscore.
Of course I could use "MyText" instead of "my_text" to avoid this
problem.
Another issue that I haven't mentioned is that the .tex file has to be
acceptable for a scientific journal.
Often, redefining commands or defining new commands are not allowed.
An ugly workaround would be to run a shell script that replaces the
alias with what I want.
I would call the shell script within my makefile, before the latex
compilation begins.
But I was hoping there would be a simple way of doing this within the
scope of latex.
Thanks again for the help.
Hi,
This is a very, very basic question, yet all the solutions I found so
far are somewhat unsatisfying.
I would like to define an alias, which I would afterward use like:
"The mechanism \ref{flow_topography_interaction} is the most effective
one when..."
with \ref{flow_topography_interaction} being replaced by another
string I defined earlier.
The answer I see everywhere is to "define a new command" as in:
\newcommand{\mycommand}{whatever I want}
But I do not find this terribly satisfying because underscores,
numbers and hyphens are not allowed within the name of commands. I can
hardly believe that there isn't a simpler and more elegant way in
LaTeX than to define a new function?
"It was a (tag) night..."
and at compilation time, latex would replace the tag by a given
string:
"It was a dark and stormy night..."
That's all. As you mentioned, one way to do this is to define a new
command:
\newcommand{\MyTag}{dark and stormy}
and then use it as:
"It was a \MyTag night..."
However, the journal to which the .tex file will be sent does not
allow me to define new latex commands.
So I'm looking for alternate solutions. The one from Ariovaldo
(involving sbox and usebox) works and I will probably end up using
it.
I don't know why you do need that, but this feature may be provided by
your editor : search it's manual for "abbreviation" and "tag
expansion"... If you often use the same shortcuts/abbreviations, it's
good to manage them from your usual-favorite editor ; but you may also
save your pairs of texts in a file you can use for external processing
or inclusion (inclusion cons. is you are limited to your input-file
syntax, TeX here, but it doesn't matter if you don't have to use the
file elsewhere)
> I would call the shell script within my makefile, before the latex
> compilation begins.
As it's a shell (or other) script it can call latex commands after sed
or whatever you use...
> But I was hoping there would be a simple way of doing this within the
> scope of latex.
>
Maaybe, maybe not. Most of us can't give you the desired answer
because we never have that need and never hear about that. If LaTeX
can't do such thing then you'll need to go deeper into TeX internals
i'm afraid.
why would they not allow newcommands but allow (new) saveboxes?
(just curious.)
cheers,
jon.
--
You received this message because you are subscribed to the Google Groups "LaTeX Users Group" group.
To post to this group, send email to latexus...@googlegroups.com.
To unsubscribe from this group, send email to latexusersgro...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/latexusersgroup?hl=en.
> this feature may be provided by
> your editor : search it's manual for "abbreviation" and "tag
> expansion"...
> As it's a shell (or other) script it can call latex commands after sed
You are right, I could do this within vim, or simply call sed within
the makefile.
Those are useful suggestions. Thanks!
jon:
> why would they not allow newcommands but allow (new) saveboxes?
You raise a good point. I bet they don't allow new saveboxes...
Another issue that I haven't mentioned is that the .tex file has to be acceptable for a scientific journal.
Often, redefining commands or defining new commands are not allowed
[...]
The journal to which the .tex file will be sent does not allow me to define new latex commands.
why would they not allow newcommands but allow (new) saveboxes?
(just curious.)
Does latex permit newcommand's in the body?
I tried the solution from Gildas this afternoon (making substitutions
with sed) and I like it.
In my makefile I add these lines
cp $(texfile).tex /tmp/
sed -i -s "s/tag1/what should replace tag1/g" /tmp/$(texfile).tex
sed -i -s "s/tag2/what should replace tag2/g" /tmp/$(texfile).tex
etc.
and then it calls latex for the compilation of /tmp/$(texfile).tex
This is probably not the most elegant solution in the world, but I'm
very happy with it.
A great thanksgiving to you all...
Pierre
> I tried the solution from Gildas this afternoon (making substitutions
> with sed) and I like it.
> In my makefile I add these lines
>
> cp $(texfile).tex /tmp/
> sed -i -s "s/tag1/what should replace tag1/g" /tmp/$(texfile).tex
> sed -i -s "s/tag2/what should replace tag2/g" /tmp/$(texfile).tex
> etc.
> and then it calls latex for the compilation of /tmp/$(texfile).tex
>
> This is probably not the most elegant solution in the world, but I'm
> very happy with it.
>
You always have to start somewhere somehow :) Maybe next step with sed
is a replacements-file that can be used with "sed -f"
<http://www.linuxask.com/questions/replace-multiple-strings-using-sed>
either from your makefile or for any non-LaTeX file that need the same
processing? (For an independent file-format --e.g. tab/coma/colon
delimited-- you'll need a language that can directly process files
--awk for example-- or can read lines into array --like python, php,
perl, and so) Anyway it's good you have a solution that satisfy you.
> It's very unfair on people like us who take care to create robust and
> reusable macros that work without destroying the document, but it's the
> price we have to pay for the publishers accepting LaTeX documents. Don't
> forget, they apply their own private style files (in addition to their
> public classes) in order to get the document typeset, and they don't want
> their macros conflicting with ones you have invented.
>
And we can't help agreeing with publishers then.