GeneralAccent with newcomand

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

Accent with newcomand

Post by Sire El Fatos »

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 :

Code: Select all

% General package
\documentclass[a4paper, 12pt]{report} % soit book soit report
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,francais]{babel}
	
%Specific packages for the command
\usepackage{xcolor}
\usepackage{soul}	
\usepackage{xstring}

% Command
\newcommand{\ps}[3]{%
	\IfEqCase{#3}{%
		{0}{\st{#1} \hl{#2}}%
		{1}{#2}%
		{-1}{#1}%
	}	
}%
	
\begin{document}
 \ps{toto}{tata}{0}
\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.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

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

Re: Accent with newcomand

Post by josephwright »

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
Post Reply