LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   [LaTeX] Placing translation in parenthesis (https://www.linuxquestions.org/questions/programming-9/%5Blatex%5D-placing-translation-in-parenthesis-879264/)

General 05-06-2011 05:16 PM

[LaTeX] Placing translation in parenthesis
 
Is there any method for placing translations in parenthesis at first occurrence? I need something similar to the acronym package, but instead, storing translations and printing brackets only after the first occurrence.

E.g. (pseudo-code):

\translation{bananas}{xiangjiao}
\translation{apples}{pingguo}

Results in:

Do you like to eat bananas (xiangjiao)? No I don't like to eat bananas.

markush 05-07-2011 05:00 PM

1 Attachment(s)
I don't understand your problem. If you want to have the translation within parenthesis, you may use newcommand
Code:

\newcommand{\translation}[2]{#1 (#2)}
which results in
Code:

\documentclass{minimal}
\newcommand{\translation}[2]{#1 (#2)}
\begin{document}
Do you like to eat \translation{bananas}{xiangjiao}? No, I don't like to eat bananas.
\end{document}

I'll append the outputfile as an attachment. But this is quiet trivial. So do you mean that you want latex to recognize the first occurance of the word which has to be translated? If so, from where should the translations come?

Markus

General 05-07-2011 05:16 PM

Quote:

Originally Posted by markush (Post 4349511)
I don't understand your problem. If you want to have the translation within parenthesis, you may use newcommand
Code:

\newcommand{\translation}[2]{#1 (#2)}
which results in
Code:

\documentclass{minimal}
\newcommand{\translation}[2]{#1 (#2)}
\begin{document}
Do you like to eat \translation{bananas}{xiangjiao}? No, I don't like to eat bananas.
\end{document}

I'll append the outputfile as an attachment. But this is quiet trivial. So do you mean that you want latex to recognize the first occurance of the word which has to be translated? If so, from where should the translations come?

Markus

Yes, I'd like to print the translation of the word in parenthesis after the first time it appears in the document, but not after later appearances of the same word. The translation could come from a list, similar to how one can make a list of acronyms using the acronym package.

markush 05-07-2011 05:33 PM

Why don't you simply use the acronym package? I tried that out
Code:

\documentclass{minimal}
\usepackage[printonlyused]{acronym}
\newacro{banana}{xiangjiao}
\begin{document}
Do you like to eat \acf{banana}? No, I don't like to eat bananas.
\end{document}

this produces the same output as the example of my last post.

Markus

General 05-13-2011 04:43 AM

Quote:

Originally Posted by markush (Post 4349537)
Why don't you simply use the acronym package? I tried that out
Code:

\documentclass{minimal}
\usepackage[printonlyused]{acronym}
\newacro{banana}{xiangjiao}
\begin{document}
Do you like to eat \acf{banana}? No, I don't like to eat bananas.
\end{document}

this produces the same output as the example of my last post.

Markus

Because that package seems the opposite of what I want.

Code:

\newacro{banana}[banana]{xiangjiao}
It first use shows 'banana (xiangjiao)', then the second time just shows 'xiangjiao'. I'd like it to first show 'banana (xiangjiao), then the second time just show 'banana'.


All times are GMT -5. The time now is 06:02 AM.