Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This is a real example of what I'm trying to understand by this question:

I'm rewriting my CV using europecv and one behavior that I don't like, is titles of personal information:

enter image description here

Lets say, I want to replace Surename(s) / First name(s) by a simple Name. In europecv.cls there are these line:

\newcommand*{\ecvname}[1]{\def\ecv@name{#1}}
.
.
.
\ecv@namekey & \large\textbf{\ecv@name}\tabularnewline[5pt]

And in a file called ecven.def there is a macro like so

\def\ecv@namekey{\ecv@utf{Surname(s) / First name(s)}}

I know by changing the line above in the original file I can achieve what I want, but I rather not to mess in the original classes (also I'm not sure if it is cool with LPPL). This answer says one can easily redefine \def, but where should I do this if document class is already using another definition?

What is the proper way of redefining documentclass macros in general and this example in particular?

Here is a MWE for your convenience:

\documentclass[10pt,notitle,nologo,totpages]{europecv}

% How to acheive the line below?
% \def\ecv@namekey{\ecv@utf{Name}}

    \ecvname{Pouya}
    \ecvtelephone{+1234567890}
    \ecvemail{foo@bar.com}

\begin{document}

  \begin{europecv}
  \ecvpersonalinfo
  \ecvsection[-1cm]{Current position}
  \ecvitem{}{In front of the computer}
  \end{europecv}

\end{document}
share|improve this question
1  
Please provide a minimal complete example. –  David Carlisle Mar 3 at 22:23
    
@DavidCarlisle, my question is quite general but I added MWE for this particular case as you asked. –  Pouya Mar 3 at 22:32
    
The question may be general but the answer can not be. Peter gave an answer (and and MWE should always be supplied so people can test their answers) but whether you can simply redefine a command depends on many factors, not least how and when the command is used, it's original definition may have been saved and be restored, or other commands may rely on the original definition or... Here it is a simple text substitution and redefinition is safe enough. –  David Carlisle Mar 3 at 23:18
add comment

2 Answers 2

up vote 4 down vote accepted

Since you are redefining a macro that contains a @, you need to add \makeatletter and \makeatother. More info on this is detailed in the references listed below.

\makeatletter
    \def\ecv@namekey{\ecv@utf{Name}}
\makeatother

enter image description here

Notes:

Code:

\documentclass[10pt,notitle,nologo,totpages]{europecv}

% How to acheive the line below?
\makeatletter
\def\ecv@namekey{\ecv@utf{Name}}
\makeatother

    \ecvname{Pouya}
    \ecvtelephone{+1234567890}
    \ecvemail{foo@bar.com}

\begin{document}

  \begin{europecv}
  \ecvpersonalinfo
  \ecvsection[-1cm]{Current position}
  \ecvitem{}{In front of the computer}
  \end{europecv}

\end{document}
share|improve this answer
    
Short and clear, thanks. Just one question before I confirm the answer: Is using \makeatletter and \makeatother always the case in such situations or there are similar situations that need different tools? –  Pouya Mar 3 at 22:38
1  
@Pouya: You just need it around macros that contain an @. The linked references have more details on this. –  Peter Grill Mar 3 at 23:03
add comment

If you just want to redefine one or two commands for a specific document or so, doing it in the preamble is probably most straightforward. If the commands contain @, you need to treat that specially:

\documentclass[10pt,notitle,nologo,totpages]{europecv}

% How to acheive the line below?
% \def\ecv@namekey{\ecv@utf{Name}}

\makeatletter% because the line includes @ we nest the redefinition this way
  \def\ecv@namekey{\ecv@utf{Name}}
\makeatother% make sure to return to normal before continuing

    \ecvname{Pouya}
    \ecvtelephone{+1234567890}
    \ecvemail{foo@bar.com}

\begin{document}

  \begin{europecv}
  \ecvpersonalinfo
  \ecvsection[-1cm]{Current position}
  \ecvitem{}{In front of the computer}
  \end{europecv}

\end{document}

Simple Name

If you want to make more extensive changes which you'll use in many documents, it is easiest to create a custom package or class to keep everything together. The details really depend on the particular case.

First, some packages and classes will use a custom configuration file if you create one. It is always worth checking for this since it is often the easiest and most robust way to customise. However, I read through the documentation of europecv and that doesn't seem to be an option in this case.

Second, for very simple cases, you can just use \input{myfile} and keep customisations in myfile.tex. Something like:

\ProvidesFile{myfile}

% some stuff here
\makeatletter% because the line includes @ we nest the redefinition this way
  \def\ecv@namekey{\ecv@utf{Name}}
\makeatother% make sure to return to normal before continuing

\endinput

Then use \input{myfile} in your preamble.

Third, you can put customisations in a style file (mystyle.sty). Again, there are different approaches but, for example:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mystyle}

\RequirePackage{some package}

\def\ecv@namekey{\ecv@utf{Name}}% note - no need for \makeatletter... in this case.

% some stuff

Fourth, you can write a custom class (myclass.cls) which loads the original class with particular options. The main reason to do this would be if it isn't possible to make the changes you wish after the main class is loaded so a style file won't work. There are different ways of doing this but, for example:

\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
[1994/12/01]% LaTeX date must December 1994 or later

\ProvidesClass{europecv-mine}

% stuff here

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{europecv}}
\ProcessOptions*
\LoadClass[10pt,notitle,nologo,totpages]{europecv}

\RequirePackage{some package}

% more stuff
\def\ecv@namekey{\ecv@utf{Name}}% note - no need for \makeatletter... in this case.

\endinput

Finally, if you want to make very extensive changes, you can copy a class or style file to a new name and modify it. For example, you could copy europecv.cls to my-europecv.cls and modify it appropriately. Note that you will not benefit from future updates to the main class unless you update your modified code. On the other hand, that may mean that your customisations are less likely to break.

Licensing is a legal issue and off-topic for this site. So I will not comment on that aspect of your question.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.