0

In most scientific journals, articles that contain foreign words or sentences, should be written in italic. In this case, I wrote an article in Indonesian, while the foreign word or phrase is the local language and English.

The first example, a respondent who was interviewed answered in the local language.

 "Nggak!"

Nggak is the vocabulary of the Java language which means "not".

The second example, a technical term like: unduh (download).

Based on a @gopalakrishna-palem answer to this question (How to create a pre-processing command that accepts plain text and generates formatted text (based on configurable options)), I tried to define:

\def\KeyWords{
% local language
nggak, 
% English
File, download, 
}

But this solution only format the first occurrence of each keyword and requires that the words or sentences are placed in \def\MyText{}, for example:

\def\MyText{
"File nggak bisa di-unduh (download)."
}

Which will produce: "File nggak bisa di-unduh (download)." [that means "File can't be downloaded].

So, the problems are:

  • How to write the word or sentence -that be formatted- as plain paragraphs?, and
  • How to format the word are repeated?
Edy Jo
  • 841

1 Answers1

1

I found an alternative solution using XeLaTeX, based on @egreg answer to this problem (automatically apply special formatting to selected words in text).

\documentclass{article}
\usepackage{color,xesearch}
\SearchList*{itwords}{\emph{#1}}{File,nggak,download}
\begin{document}
''File nggak bisa di-unduh (download).''
\end{document} 

It works! But @egreg says, "Don't use it. If you want to specially mark a word, use a macro." How to do this?

Edy Jo
  • 841
  • 1
    I think egreg might refer to a macro such as \newcommand{\foreignword}[1]{\emph{#1}} and use that as \foreignword{File} \foreignword{nggak} bisa di-unduh (\foreignword{download}). Of course that is less automated, but somewhat clearer and more robust. – moewe Jan 02 '14 at 14:33
  • @moewe, would not it be easier to write: '\emph{File nggak} bisa di-unduh \emph{download}.' – Edy Jo Jan 02 '14 at 14:42
  • Most certainly, but what if you decide to set foreign words in bold or red? If you use a macro it's as easy as \newcommand{\foreignword}[1]{\textbf{#1}}. In LaTeX one aims to use semantic markup using macros describe what is being shown not how it is to be typeset. – moewe Jan 02 '14 at 14:50
  • shortcoming of this solution is the "File" and "file" are considered as two different words. So it is necessary to define \SearchList{itwords}{\emph{#1}}{File,file*,nggak,download} – Edy Jo Jan 02 '14 at 14:51
  • the point is to prevent the author forgot to format the word according to the rules of scientific writing. – Edy Jo Jan 02 '14 at 14:58
  • 1
    I see your point, and quite agree that it is desirable. But think about it that way: What prevents an author from sending out a manuscript that contains spelling errors, forgotten commas, stylistically questionable writing, unclear sentences? It would be awesome if LaTeX could do that, but the only way to prevent that is proofreading. Sometimes over-auttomatification (is that even a word, probably not) is not the best way to go, but if it works for you... (See also egreg's caveat in his answer.) – moewe Jan 02 '14 at 15:11
  • 1
    Shouldn't these words (at least the English ones) be marked as such for hyphenation purposes? That is, using babel (or I assume polyglossia offers similar functionality). If it is just a few words, you can always check for problems but otherwise you risk poor line-breaking etc. because TeX won't apply e.g. the hyphenation rules for English if it doesn't know that 'download' is English (unless this happens to be on the Indonesian list and hyphenates in the same way). – cfr Jan 02 '14 at 23:40