jgm / pandoc

Universal markup converter
https://pandoc.org
Other
33.88k stars 3.34k forks source link

Lang variable not respected in babel output #566

Closed cmmp closed 12 years ago

cmmp commented 12 years ago

Hi,

I'm trying to create a beamer presentation and setting the lang variable, so that auto-generated text and hyphenation is correct.

This is my sample document (in portuguese):

% Teste de Apresentação
% Cássio
% 14 de julho de 2012

# Primeiro Slide

## Teste 1

* Bullet 1
* Bullet 2

I'm using the command pandoc --variable lang=brazil -t beamer apre.md -o slides.pdf to generate my pdf.

In the second page of the document I get "Section 1: Primeiro Slide". This should have been "Seção 1: Primeiro Slide" if babel was correctly set.

Any ideas what gives?

pandoc version:

$ pandoc -v
pandoc 1.9.4.2
Compiled with citeproc-hs 0.3.4, texmath 0.6.0.6, highlighting-kate 0.5.1.
Syntax highlighting is supported for the following languages:
    Actionscript, Ada, Alert, Alert_indent, Apache, Asn1, Asp, Awk, Bash,
    Bibtex, Boo, C, Changelog, Clojure, Cmake, Coffeescript, Coldfusion,
    Commonlisp, Cpp, Cs, Css, D, Diff, Djangotemplate, Doxygen, Dtd, Eiffel,
    Email, Erlang, Fortran, Fsharp, Gnuassembler, Go, Haskell, Haxe, Html, Ini,
    Java, Javadoc, Javascript, Json, Jsp, Latex, Lex, LiterateHaskell, Lua,
    Makefile, Mandoc, Matlab, Maxima, Metafont, Mips, Modula2, Modula3,
    Monobasic, Nasm, Noweb, Objectivec, Objectivecpp, Ocaml, Octave, Pascal,
    Perl, Php, Pike, Postscript, Prolog, Python, R, Relaxngcompact, Rhtml, Ruby,
    Scala, Scheme, Sci, Sed, Sgml, Sql, SqlMysql, SqlPostgresql, Tcl, Texinfo,
    Verilog, Vhdl, Xml, Xorg, Xslt, Xul, Yacc, Yaml
Copyright (C) 2006-2012 John MacFarlane
Web:  http://johnmacfarlane.net/pandoc
This is free software; see the source for copying conditions.  There is no
warranty, not even for merchantability or fitness for a particular purpose.

thanks, Cássio

jgm commented 12 years ago

+++ Cássio M. M. Pereira [Jul 13 12 21:33 ]:

Hi,

I'm trying to create a beamer presentation and setting the lang variable, so that auto-generated text and hyphenation is correct.

This is my sample document (in portuguese):

% Teste de Apresentação
% Cássio
% 14 de julho de 2012

# Primeiro Slide

## Teste 1

* Bullet 1
* Bullet 2

I'm using the command pandoc --variable lang=brazil -t beamer apre.md -o slides.pdf to generate my pdf.

In the second page of the document I get "Section 1: Primeiro Slide". This should have been "Seção 1: Primeiro Slide" if babel was correctly set.

Any ideas what gives?

pandoc version:

Not sure. Why don't you first try generate a .tex file (instead of .pdf):

pandoc -V lang=brazil -s -t beamer apre.md -o slides.tex

Then you can check the .tex file to make sure the right babel options are being set. Perhaps 'brazil' is not the right name to use? Try 'brazilian'?

cmmp commented 12 years ago

Hi John,

brazil is one of the correct options.

This is strange, I'm not sure whose bug this is anymore.

Following your suggestion, I generated a .tex and modified my example to the following:

% Teste de Apresentação
% Cássio
% \today

# Primeiro Slide

## Teste 1

* Bullet 1
* Bullet 2

here's the tex output:

\documentclass[ignorenonframetext,]{beamer}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifxetex
  \usepackage{fontspec,xltxtra,xunicode}
  \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\else
  \ifluatex
    \usepackage{fontspec}
    \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
  \else
    \usepackage[utf8]{inputenc}
  \fi
\fi
% Comment these out if you don't want a slide with just the
% part/section/subsection/subsubsection title:
\AtBeginPart{\frame{\partpage}}
\AtBeginSection{\frame{\sectionpage}}
\AtBeginSubsection{\frame{\subsectionpage}}
\AtBeginSubsubsection{\frame{\subsubsectionpage}}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\setcounter{secnumdepth}{0}
\usepackage[brazil]{babel}

\title{Teste de Apresentação}
\author{Cássio}
\date{\today}

\begin{document}
\frame{\titlepage}

\section{Primeiro Slide}

\begin{frame}\frametitle{Teste 1}

\begin{itemize}
\item
  Bullet 1
\item
  Bullet 2
\end{itemize}

\end{frame}

\end{document}

The \today is correctly translated to portuguese, but the second page still shows "Section 1" instead of "Seção 1". My guess is that \sectionpage is not getting translated by babel, but it appears that \sectionpage is not even defined by beamer (according to http://cse.unl.edu/~shantk/files/beameruserguide-1.pdf and http://www.latex-community.org/forum/viewtopic.php?f=5&t=13490#p51021)... so that's probably why babel is not making the translation.

do you know how I would go about translating \sectionpage or disabling it without manually tweaking the .tex?

thanks, Cássio

jgm commented 12 years ago

+++ Cássio M. M. Pereira [Jul 14 12 12:38 ]:

Hi John,

brazil is one of the correct options.

This is strange, I'm not sure whose bug this is anymore.

Following your suggestion, I generated a .tex and modified my example to the following:

% Teste de Apresentação
% Cássio
% \today

# Primeiro Slide

## Teste 1

* Bullet 1
* Bullet 2

here's the tex output:

\documentclass[ignorenonframetext,]{beamer}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifxetex
  \usepackage{fontspec,xltxtra,xunicode}
  \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\else
  \ifluatex
    \usepackage{fontspec}
    \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
  \else
    \usepackage[utf8]{inputenc}
  \fi
\fi
% Comment these out if you don't want a slide with just the
% part/section/subsection/subsubsection title:
\AtBeginPart{\frame{\partpage}}
\AtBeginSection{\frame{\sectionpage}}
\AtBeginSubsection{\frame{\subsectionpage}}
\AtBeginSubsubsection{\frame{\subsubsectionpage}}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\setcounter{secnumdepth}{0}
\usepackage[brazil]{babel}

\title{Teste de Apresentação}
\author{Cássio}
\date{\today}

\begin{document}
\frame{\titlepage}

\section{Primeiro Slide}

\begin{frame}\frametitle{Teste 1}

\begin{itemize}
\item
  Bullet 1
\item
  Bullet 2
\end{itemize}

\end{frame}

\end{document}

The \today is correctly translated to portuguese, but the second page still shows "Section 1" instead of "Seção 1". My guess is that \sectionpage is not getting translated by babel, but it appears that \sectionpage is not even defined by beamer (according to http://cse.unl.edu/~shantk/files/beameruserguide-1.pdf and http://www.latex-community.org/forum/viewtopic.php?f=5&t=13490#p51021)... so that's probably why babel is not making the translation.

do you know how I would go about translating \sectionpage or disabling it without manually tweaking the .tex?

Yes, that's easy. You just need to comment out some lines in the template:

% Comment these out if you don't want a slide with just the % part/section/subsection/subsubsection title: \AtBeginPart{\frame{\partpage}} \AtBeginSection{\frame{\sectionpage}} \AtBeginSubsection{\frame{\subsectionpage}} \AtBeginSubsubsection{\frame{\subsubsectionpage}}

cmmp commented 12 years ago

Hi John,

Ok. Commenting the lines on the template (at /home/user/.cabal/share/pandoc-1.9.4.2/templates/default.beamer for future reference) did the trick.

I dug some more on this and \sectionpage IS actually defined by beamer (see the latest user manual at http://www.laqee.unal.edu.co/tex-archive/macros/latex/contrib/beamer/doc/beameruserguide.pdf). The problem seems to be that babel does not provide translations for all strings that beamer uses, so they suggest the translator package. The downside is that the translation of those new strings have to be done manually or using a dictionary. I searched my system and could not find a Brazilian portuguese dictionary for translator, and I guess many other languages don't have one installed by default either (maybe the aspell dictionaries could be used, but this would have to rely on the user having those installed).

I think that considering these issues, pandoc should only use those lines with \sectionpage, \subsectionpage, etc, if lang is not defined or is equal to English, as probably all other languages will get "Section 1" instead of their own definition.

best regards, Cássio

jgm commented 12 years ago

I came up with a better approach. Try this in your template:

% Comment these out if you don't want a slide with just the
% part/section/subsection/subsubsection title:
\let\insertpartnumber\relax
\let\partname\relax
\let\insertsectionnumber\relax
\let\sectionname\relax
\let\insertsubsectionnumber\relax
\let\subsectionname\relax
\AtBeginPart{\frame{\partpage}}
\AtBeginSection{\frame{\sectionpage}}
\AtBeginSubsection{\frame{\subsectionpage}}
cmmp commented 12 years ago

Hi John,

that works for me! only the section name appears, so no problems with translations.

jgm commented 12 years ago

OK, I think I may use this approach for the default template. It is consistent with the other slide formats, which don't use the 'Section #'.

+++ Cássio M. M. Pereira [Aug 24 12 04:55 ]:

Hi John,

that works for me! only the section name appears, so no problems with translations.

-- Reply to this email directly or [1]view it on GitHub. [xJAuenYDiIoVt3LF3y6848DAslDCyjnQ6q-QyN4VMN9eC1gnfeW5vibL-y3RVOzt.gif]

References

  1. https://github.com/jgm/pandoc/issues/566#issuecomment-7999312