General\newcommand in \input'ed file?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
mike-klemin
Posts: 8
Joined: Fri Feb 18, 2011 9:50 pm

\newcommand in \input'ed file?

Post by mike-klemin »

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
Last edited by mike-klemin on Wed Mar 30, 2011 8:59 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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?

Post by Stefan Kottwitz »

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
LaTeX.org admin
mike-klemin
Posts: 8
Joined: Fri Feb 18, 2011 9:50 pm

Re: \newcommand in \input'ed file?

Post by mike-klemin »

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. :D
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

\newcommand in \input'ed file?

Post by localghost »

mike-klemin wrote:[…] Now everything works as supposed. […]
Then please mark the topic (not the last post) accordingly as written in Section 3 of the Board Rules (to be read before posting).


Thorsten
Post Reply