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.

I compile my tex file with xelatex

and I want to renew the \lstlistlistingname

In this case, I just use \renewcommand to do this job.

It success if I put this command after package in tex file

but how can I move this command to .sty file.

Notice, The new lstlistlistingname is some CJK character and the file encoding with UTF-8

share|improve this question
    
? Where is your problem. If it is a personal style you can use utf8 chars if you want. –  Ulrike Fischer Jun 21 '12 at 17:46
    
Do you input CJK enconding first and then redefine lstlistlistingname? –  robert.marik.cz Jun 21 '12 at 19:07
    
Which .sty file do you put it in? Please provide a miniaml working example. –  Leo Liu Jun 22 '12 at 10:04
add comment

1 Answer 1

up vote 3 down vote accepted

This example works for me:

The package:

% encoding: UTF-8
% ccode.sty
\ProvidesPackage{ccode}[2012/06/22 test listings]
\RequirePackage{xeCJK}
\setCJKmainfont{SimSun}
\RequirePackage{listings}
\renewcommand\lstlistingname{代码}
\lstnewenvironment{ccode}[2][]{\lstset{language=C,caption=#2,#1}}{}
\endinput

The test document:

% encoding: UTF-8
% foo.tex
\documentclass{article}
\usepackage{ccode}
\begin{document}
\begin{ccode}{测试}
#include <stdio.h>
int main()
{
    puts("Hello world.");
    return 0;
}
\end{ccode}
\end{document}
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.