Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following:

\newif\ifabrvused
\abrvusedfalse

\def\abrv#1#2{%
  \ifabrvused\else%
    \newwrite\@loa%
    \immediate\openout\@loa=\jobname.loa%
    \write0{    Test}
    \abrvusedtrue%
  \fi%

  \@ifundefined{abrv@#1}{%
    \expandafter\def\csname abrv@#1\endcsname{#2}%
    \immediate\write\@loa{\unexpanded{\item[\textbf{#1}]#2}}%
    {#2 (\textbf{#1})}%
  }{%
  {\textbf{#1}}%
  }%
}

The intention is that the first time its called it opens the aux file for writing. My problem is, that the open part (ifabrvused\else) is getting called twice. I was able to find out that its getting called for the first use within my begin{abstract} and the rest of the document? What am I missing. If its intended to do so, how can i code around it?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Inside the environment abstract you are inside a group. \abrvusedtrue is a local assignment (\let\ifabrvused\iftrue). The switch is reset to false after the environment. Use \global\abrvusedtrue instead.

share|improve this answer
    
Thanks it works. Just noticed how the line '{#2 (\textbf{#1})}%' always starts a newline before writing the text. Happen to know why? –  s093294 Jan 13 '13 at 18:57
1  
@s093294 You have an empty line in your definition that causes the end of the previous paragraph. –  Heiko Oberdiek Jan 13 '13 at 20:12
    
\@ifundefined{abrv@#1}{% do not seem to work. Its written to aux file for both abstract and and document. I assume its the same problem, just dont know where to tell it to use global for that –  s093294 Jan 26 '13 at 0:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.