This is Haji's MSc thesis codes. Use it with ultimate caution.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sharif-glossary.tex 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. % !TEX encoding = UTF-8 Unicode
  2. \glsdisablehyper % disable hyperlinks
  3. \newglossarystyle{persian-to-english}{%
  4. % \glossarystyle{listdotted}% the base style
  5. % put the glossary in a two column page and description (as in listdotted style) environment:
  6. \renewenvironment{theglossary}%
  7. {\begin{multicols}{2}\begingroup \flushleft }%
  8. {\endgroup \end{multicols}}%
  9. % \renewenvironment{theglossary}{}{}%
  10. % have nothing after \begin{theglossary}:
  11. \renewcommand*{\glossaryheader}{}%
  12. % have nothing between glossary groups:
  13. \renewcommand*{\glsgroupheading}[1]{}%
  14. \renewcommand*{\glsgroupskip}{}%
  15. % set how each entry should appear: \glossaryentryfield{label}{formatted name}{description}{symbol}{number list}
  16. \renewcommand*{\glossaryentryfield}[5]{%
  17. \glstarget{##1}{##2}% persian term
  18. \dotfill%dots
  19. \space \lr{##3} \\%
  20. % \dotfill%
  21. % \space {##5} \\%translation term
  22. }%
  23. % set how sub-entries appear:
  24. \renewcommand*{\glossarysubentryfield}[6]{%
  25. \glossaryentryfield{##2}{##3}{##4}{##5}{##6}%
  26. }%
  27. }
  28. % ========= Glossary styles (put in files) =========
  29. \newglossarystyle{english-to-persian}{%
  30. % \glossarystyle{listdotted}% the base style
  31. % put the glossary in a two column page and description (as in listdotted style) environment:
  32. \renewenvironment{theglossary}%
  33. {\begin{multicols}{2}\begingroup \flushright }%
  34. {\endgroup \end{multicols}}%
  35. % \renewenvironment{theglossary}{\Latin{}}{\Persian{}}%
  36. % have nothing after \begin{theglossary}:
  37. \renewcommand*{\glossaryheader}{}%
  38. % have nothing between glossary groups:
  39. \renewcommand*{\glsgroupheading}[1]{}%
  40. \renewcommand*{\glsgroupskip}{}%
  41. % set how each entry should appear:
  42. \renewcommand*{\glossaryentryfield}[5]{%
  43. \glstarget{##1}{##2}% persian term
  44. \dotfill%dots
  45. \space \rl{##3} \\%translation term
  46. }%
  47. % set how sub-entries appear:
  48. \renewcommand*{\glossarysubentryfield}[6]{%
  49. \glossaryentryfield{##2}{##3}{##4}{##5}{##6}%
  50. }%
  51. }
  52. % ========= GLOSSARIES =========
  53. \newglossary{p2e-terms}{fa.gls}{fa.glo}{واژه‌نامه فارسی به انگلیسی} % persian to english
  54. \newglossary{e2p-terms}{en.gls}{en.glo}{English to Persian Glossary} % english to persian
  55. \newcommand{\newtrans}[3][]{% params: persian, english translations, first optional is a key
  56. \newtranspl[#1]{#2}{#3}{#2‌ها}%
  57. }
  58. \newcommand{\newtranspl}[4][]{% params: persian, english, plural form of persian, first optional is a key
  59. \ifthenelse{\isempty{#1}}{\def\key{#2}}{\def\key{#1}}%
  60. \newglossaryentry{en:\key}{type={e2p-terms}, name={#3}, description={#2}}% english glossary
  61. % \newglossaryentry{fa:\key}{type={p2e-terms}, name={#2}, description={#3}}% persian glossary
  62. \newglossaryentry{fa:\key}{type={p2e-terms}, name={#2}, plural={#4}, description={#3}}% persian glossary
  63. }
  64. % ========= END OF GLOSSARIES =========
  65. % Show a translation and footnote it.
  66. % Params (the same as \glsdisplayfirst):{text}{description}{symbol}{insert}
  67. % insert can possibly be filled with some notes on the translation.
  68. \newcommand{\showTransFirst}[4]{% translation for the first time
  69. \ifthenelse{\isempty{#4}}%
  70. {\textit{#1}\LTRfootnote{ #2}}% if #4 is empty (no notes)
  71. %%%{\textit{#1}\LTRfootnote{{#2} #4}}% if #4 is not empty
  72. {\textiranic{#1}\LTRfootnote{{#2} #4}}% if #4 is not empty
  73. %{\textit{#1}\footnote{ \lr{#2}؛ #4}}% if #4 is not empty
  74. }
  75. \newcommand{\showTrans}[4]{% translation for next times
  76. \ifthenelse{\isempty{#4}}%
  77. {{#1}}% if #4 is empty (no notes)
  78. {\textit{#1}\footnote{#4}}% if #4 is not empty
  79. }
  80. \defglsdisplayfirst[p2e-terms]{\showTransFirst{#1}{#2}{#3}{#4}}% protect fragile commands
  81. \defglsdisplay[p2e-terms]{\showTrans{#1}{#2}{#3}{#4}}
  82. % Symbol may temporarily used to keep some notes on the translation.
  83. % It must be replaced with a user1 key which now raises error, texlive must be upgraded.
  84. \newcommand{\term}[2][]{%
  85. \glsadd{en:#2}%
  86. \ifthenelse{\isempty{#1}}{\gls{fa:#2}}{\gls{fa:#2}[#1]}%
  87. }
  88. \newcommand{\termpl}[2][]{%
  89. \glsadd{en:#2}%
  90. \ifthenelse{\isempty{#1}}{\glspl{fa:#2}}{\glspl{fa:#2}[#1]}%
  91. }
  92. %=========== Print Glossaries ===============
  93. % see: http://www.parsilatex.com/forum/SMF/index.php?topic=345.0
  94. %\glossarystyle{persian-to-english}
  95. %\def\glossaryname{واژه‌نامه فارسی به انگلیسی}
  96. %\printglossaries
  97. \newcommand{\printpersianglossary}[1][واژه‌نامه فارسی به انگلیسی]{{%
  98. \phantomsection % hyperref: enable hyperlinking from the table of contents to this point
  99. \addcontentsline{toc}{chapter}{#1} % add a line in the Table of Contents (first option, toc), it will be like the ones
  100. \renewcommand{\glossarymark}[1]{\markboth{##1}}% correct handling of page header
  101. \printglossary[type={p2e-terms},style={persian-to-english},title={#1}]%
  102. }}
  103. \newcommand{\printenglishglossary}[1][واژه‌نامه انگلیسی به فارسی]{{%
  104. \phantomsection % hyperref: enable hyperlinking from the table of contents to this point
  105. \addcontentsline{toc}{chapter}{#1} % add a line in the Table of Contents (first option, toc), it will be like the ones
  106. \renewcommand{\glossarymark}[1]{\markboth{##1}}% correct handling of page header
  107. \begin{latin}%
  108. \printglossary[type={e2p-terms},style={english-to-persian},title={\rl{#1}}]%
  109. \end{latin}%
  110. }}
  111. % Reset the first-use flag of the transaltion glossareis
  112. \newcommand{\resettranslations}{\glsresetall[e2p-terms,p2e-terms]}