LaTeX forum ⇒ GeneralAccent with newcomand

LaTeX specific issues not fitting into one of the other forums of this category.
Sire El Fatos
Posts: 3
Joined: Tue Oct 15, 2013 11:36 am

Accent with newcomand

Postby Sire El Fatos » Tue Dec 03, 2013 11:53 am

Dear latex users,

I'd greatly appreciate any help with this issue.

Actually, I created a new command (with 3 arguments) in order to have a basic correction functionality.

It's working for any text without accent like the minimal example below :
  1. % General package
  2. \documentclass[a4paper, 12pt]{report} % soit book soit report
  3. \usepackage[utf8]{inputenc}
  4. \usepackage[T1]{fontenc}
  5. \usepackage[english,francais]{babel}
  6.  
  7. %Specific packages for the command
  8. \usepackage{xcolor}
  9. \usepackage{soul}
  10. \usepackage{xstring}
  11.  
  12. % Command
  13. \newcommand{\ps}[3]{%
  14. \IfEqCase{#3}{%
  15. {0}{\st{#1} \hl{#2}}%
  16. {1}{#2}%
  17. {-1}{#1}%
  18. }
  19. }%
  20.  
  21. \begin{document}
  22. \ps{toto}{tata}{0}
  23. \end{document}


If I put any accent (-, é, è, ', ", ...), I get several errors.

Normally, accents are managed by the package \usepackage[T1]{fontenc} excepted for my command...

Do you have any ideas to solve this problem ?

Thank you in advance for your precious help.

Tags:

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm
Contact:

Postby josephwright » Wed Dec 04, 2013 10:30 am

Using standard (8-bit) pdfTeX, accents may or may not work in command names. Using them in 'text' does not require they are single characters in their underlying representation, but using them in command names does. Thus it's normally regarded as safest not to use accents in command names.

If you save your file in UTF-8 format and use a suitable engine (LuaTeX or XeTeX) then you can use any UTF-8 (Unicode) character in a command name.
Joseph Wright


Return to “General”

Who is online

Users browsing this forum: Google [Bot] and 6 guests