I have a "preamble.tex" file where I define some things and couple of \newcommands, but it looks like master document (which has \input{preabmle}) does not see definition of my newcommand, but other things are apply successfully like \usepackage{}.
if there any possibility to make it working? I making various docs and I would like
General ⇒ \newcommand in \input'ed file?
-
- Posts: 8
- Joined: Fri Feb 18, 2011 9:50 pm
\newcommand in \input'ed file?
Last edited by mike-klemin on Wed Mar 30, 2011 8:59 pm, edited 2 times in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Re: \newcommand in \input'ed file?
Hi Mike-Klemin,
it's possible. It's even the expected behavior. They won't be seen if they are defined within a group or environment. Just show example code, what you are doing which doesn't work.
Stefan
it's possible. It's even the expected behavior. They won't be seen if they are defined within a group or environment. Just show example code, what you are doing which doesn't work.
Stefan
LaTeX.org admin
-
- Posts: 8
- Joined: Fri Feb 18, 2011 9:50 pm
Re: \newcommand in \input'ed file?
Hello Stefan!
I feel so dumb...
The problem was in encoding, the preamble was encoded differently, and I had these extra characters in \newcommand
It was so hard to figure for me...I using Lyx 1.6 and it giving very little debug options.
I tried to reproduce it in texMaker and, it worked just fine (since for texmaker both preamble and master were in same encoding as I made them from scratch) and after reading your post that it supposed to be working, and my texmaker experience.. I got a clue of what the hell happening
Edit: yes, the problem was with encoding, by some strange reason Lyx default encoding for Cyrillic is KOI8-R and not UTF-8, so I had my main master file in KOI8-R and tried to \input UTF-8 preamble, which caused some strange errors, nature of which I just couldn't get, because I just made couple of copy/paste...
Now everything works as supposed.
I feel so dumb...
The problem was in encoding, the preamble was encoded differently, and I had these extra characters in \newcommand

It was so hard to figure for me...I using Lyx 1.6 and it giving very little debug options.
I tried to reproduce it in texMaker and, it worked just fine (since for texmaker both preamble and master were in same encoding as I made them from scratch) and after reading your post that it supposed to be working, and my texmaker experience.. I got a clue of what the hell happening

Edit: yes, the problem was with encoding, by some strange reason Lyx default encoding for Cyrillic is KOI8-R and not UTF-8, so I had my main master file in KOI8-R and tried to \input UTF-8 preamble, which caused some strange errors, nature of which I just couldn't get, because I just made couple of copy/paste...
Now everything works as supposed.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
\newcommand in \input'ed file?
Then please mark the topic (not the last post) accordingly as written in Section 3 of the Board Rules (to be read before posting).mike-klemin wrote:[…] Now everything works as supposed. […]
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10