LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-06-2011, 05:16 PM   #1
General
Member
 
Registered: Aug 2005
Distribution: Debian 7
Posts: 526

Rep: Reputation: 31
[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.
 
Old 05-07-2011, 05:00 PM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
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
Attached Files
File Type: pdf mini.pdf (14.7 KB, 24 views)
 
Old 05-07-2011, 05:16 PM   #3
General
Member
 
Registered: Aug 2005
Distribution: Debian 7
Posts: 526

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by markush View Post
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.
 
Old 05-07-2011, 05:33 PM   #4
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
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
 
Old 05-13-2011, 04:43 AM   #5
General
Member
 
Registered: Aug 2005
Distribution: Debian 7
Posts: 526

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by markush View Post
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'.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] closing parenthesis script cruzdelsur Programming 5 08-30-2010 09:55 AM
Program accepting Latex source as input and outputs Latex file. stf92 Slackware 5 12-10-2009 01:56 AM
LaTeX, placing graphics in header edgjerp Programming 3 05-20-2009 01:42 PM
preventing LaTeX from placing a blank page first edgjerp Linux - Software 4 12-14-2006 09:34 PM
Can't rename file with parenthesis in name pleasehelp Linux - Newbie 4 03-16-2004 03:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration