Generalinclude a macro

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
meliahabib
Posts: 9
Joined: Wed Aug 20, 2008 6:53 pm

include a macro

Post by meliahabib »

hi all!
i have a question ,if someone can help me please.
i write a file that contains multiple \new command ,how can i include it in my program.tex ,and which extension i must give it to mymacro.
i tried the extension .tex ,and i put it in the same directory where program.tex is saved ,but i get this error: I can't find file `{mymacro.tex}'.
thanks.
Melia.

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

include a macro

Post by Stefan Kottwitz »

Hi Melia,

how do you include the file? It should have the extension .tex, the name mymacro.tex is correct. I would include it this way:

Code: Select all

\input{mymacro}
Does this work for you?

Stefan
LaTeX.org admin
meliahabib
Posts: 9
Joined: Wed Aug 20, 2008 6:53 pm

include macro and supress spaces.

Post by meliahabib »

hi stephan
thx.
but i tried this possibility.
\input{mymacro}
and
\input{C:\Program Files\MiKTeX 2.7\tex\latex\base\mymacro.tex}
but the error stills.
this is mymacro.
\documentclass[12pt]{article}
\usepackage[francais]{babel}
\usepackage{arabtex}
\begin{document}
\parskip 5pt
\newcommand{\ا}{A}
\newcommand{\ب}{b}
\newcommand{\ص}{.s}
\newcommand{\ح}{.h}
\end{document}

and in my program.tex

\documentclass[12pt]{article}
\usepackage{arabtex}
\setarab
\transtrue
\arabtrue
\begin{document}
\begin{RLtext}
\input{macro.tex}
\ص\ب\ا\ح
\end{RLtext}
\end{document}
i have no error if i use this solution :i write these \newcommands in the program.tex and if i don't include the file .
but i would perform my program.tex so i need to include the file.

my second question :when i use the first solution ,i am having spaces between arabic letters ,
that are not wanted ,so is there is a solution to suppress these spaces.
sorry ,because my questions are long.
thank you very very much.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

include a macro

Post by Stefan Kottwitz »

Hi Melia,

please don't open a new topic, you can use your old topic containing the first question, just click on Reply. Open a new topic only if you have a different question or a new issue.
  • there are different filenames: in program.tex it has to be \input{mymacro} instead of \input{macro.tex}.
  • mymacro.tex must not contain \documentclass, \usepackage, \begin{document} or \end{document}. Just remove those lines.
Stefan
LaTeX.org admin
meliahabib
Posts: 9
Joined: Wed Aug 20, 2008 6:53 pm

Re: include a macro

Post by meliahabib »

hi
sorry ,because i typed a different name,but in the program,i am writing the correct name.
i suppress that you told me,but unfortunately,the error stills.
so ,if there a solution please.
thank you.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

include a macro

Post by Stefan Kottwitz »

Try to use \input{mymacro} outside the RLtext environment:

Code: Select all

\input{mymacro}
\begin{RLtext}
\ص\ب\ا\ح
\end{RLtext}
Stefan
LaTeX.org admin
meliahabib
Posts: 9
Joined: Wed Aug 20, 2008 6:53 pm

Re: include a macro

Post by meliahabib »

hi stephan
i tried to put \input{mymacro} before \begin{RLtext},but the same error.
is it from the directory where i put it in?where i must put it?
this is the errors:
Error: ! LaTeX Error: File `mymacro.tex' not found.
Error: ! Emergency stop.
thank you.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

include a macro

Post by Stefan Kottwitz »

Hi Melia,

first you may try this: open MiKTeX Options in the start menu and click the button Refresh FNDB.
Then try again to compile your document.

If it doesn't work try it with putting mymacro.tex into the same directory like your program.tex main document.

As you can see the error message has changed, from I can't find file `{mymacro.tex}'. to LaTeX Error: File `mymacro.tex' not found. after moving the \input line upwards. That should have been nevertheless necessary.

Stefan
LaTeX.org admin
meliahabib
Posts: 9
Joined: Wed Aug 20, 2008 6:53 pm

Re: include a macro

Post by meliahabib »

hi
i try this:i open MiKTeX Options in the start menu and i click the button Refresh FNDB.
Then i try again to compile your documentand i put mymacro.tex in the same directory like program.tex main document.
but ,unfortunately,i couldn't correct the error:LaTeX Error: File `mymacro.tex' not found.
thx very much.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

include a macro

Post by Stefan Kottwitz »

Hi Melia,

I had tested it, with mymacro.tex in the same folder like program.tex, it worked.
To be sure that we understand each other and that we speak about the same code, please attach again your files program.tex, mymacro.tex and the logfile program.log. With enough information this should be solvable.
You can attach them as file attachments in the forum, see the Browse-Button below, next to Filename.

Stefan
LaTeX.org admin
Post Reply