New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] when lstset{mathescape=true}, lstinline cannot work well #4716
Comments
|
Sorry, I don't know hs language, I don't know how to edit source directly. |
|
Thank you for submitting a bug report. However, we cannot improve pandoc or help you unless you give us all of the following information:
A small test case (just a few lines) is ideal. If your input is large, try to whittle it down to a minimum working example. |
|
I had pointed the source code, pandoc version 2.2.1. in the source code, it forget to process when mathescape = true. so every special string would be converted. but string between $ and $, as math express should not be converted. I will make a small bug code. sorry. |
|
pandoc exact command all the file all in folder i had submit. ps:
all related words was speak in result.pdf bug source in https://github.com/jgm/pandoc/blob/master/src/Text/Pandoc/Writers/LaTeX.hs?#L1048#L1053 |
|
I still don't quite understand, since you provide a lot of information, but the example is neither minimal (best would be a simple |
|
@jgm I think it is simple enough, even the source code, I had already circled. before complete escape, take if it is mathescape, then can take convert in double $? |
|
I upload a simple example, Thank you. |
Previously the LaTeX writer created invalid LaTeX
when `--listings` was specified and a code span occured
inside emphasis or another construction.
This is because the characters `%{}\` must be escaped
in lstinline when the listinline occurs in another
command, otherwise they must not be escaped.
To deal with this, adoping Michael Kofler's suggestion,
we always wrap lstinline in a dummy command `\passthrough`,
now defined in the default template if `--listings` is
specified. This way we can consistently escape the
special characters.
Closes jgm#1629.
|
I had ref to dotlambda@730796e#comments I think the person who add this feature can understand this bug. Thank you. |
|
The LaTeX writer doesn't have any idea what is in the template and (with a minor exception) doesn't adjust its behavior based on that. It definitely doesn't parse the template. Moreover, there is currently no setting corresponding to mathescape=true. |
|
I had contacted with the listings package author, here is their reply. and there two files. |
3 similar comments
|
I had contacted with the listings package author, here is their reply. and there two files. |
|
I had contacted with the listings package author, here is their reply. and there two files. |
|
I had contacted with the listings package author, here is their reply. and there two files. |
%%% test_ifmathescape.tex ---
%
%% Author: j.hoffmann@fh-aachen.de
%% Version: $Id: test_ifmathescape.tex 0 2018/09/21 12:23:46 ax006ho Exp $
\RequirePackage{ifpdf}
\RequirePackage{ifluatex}
% \documentclass[12pt,a4paper,english,ngerman]{article}
\documentclass[12pt,a4paper,english,ngerman]{scrartcl}
\usepackage{etex}
\makeatletter
\@ifclassloaded{article}{%
\usepackage{typearea}
}{}
\makeatother
\ifluatex
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\fontspec{Latin Modern Roman}
\else
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\fi
\usepackage{babel}
\usepackage{listings}
\begin{document}
\begin{itemize}
\item Use mathescape local: \lstinline|$x_1$|
vs. \lstinline[mathescape]|$x_1$|.
\item Use mathescape global in the current environment:
\lstset{mathescape=true}\lstinline|$x_1$|
vs. \lstinline[mathescape]|$x_1$|.
But: \lstinline[mathescape=false]|$x_1$|
vs. \lstinline[mathescape]|$x_1$|.
\end{itemize}
Outside the environment:
\makeatletter
\lst@ifmathescape mathescape is true\else mathescape is false.\fi
\makeatother
\lstset{mathescape=true}
And now after setting mathescape global again:
\makeatletter
\lst@ifmathescape mathescape is true\else \fi
\makeatother
As macro one can write in \LaTeX:
\makeatletter
\newcommand{\ifmathescape}[2]{%
\lst@ifmathescape #1\else #2\fi
}
\makeatother
and use it like \ifmathescape{mathescape is true.}{mathescape is false.}
\lstset{mathescape=false} or
\ifmathescape{mathescape is true.}{mathescape is false.}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% TeX-engine: default
%%% TeX-source-correlate-mode: t
%%% mode: flyspell
%%% ispell-local-dictionary: "deutsch8"
%%% End:
|
|
I am sorry for that. my phone works slowly, I press too many times comment button. i think it can add one condition in the output of pandoc. \ifdisableEscapeString then, user could define themselves \newif\ifEscapeString in other place. for example the \ifmathescape |
|
Good. Perhaps instead of using |
Solve bug jgm#4716
Solve bug jgm#4716, now, the old text can works, but it need `usepackage{etoolbox}` for `\ifdef`. if user want to use in mathescape=true for `listings` package, the following can be added to the template when needed. ```latex \makeatletter \newcommand{\ifmathescape}[2]{% \lst@ifmathescape jgm#1\else jgm#2\fi } \makeatother \let\ifdisableEscapeString\ifmathescape ```
|
I find that this problem still. I want to solve it. Have you any suggestion? Thank you. |

Watch source https://github.com/jgm/pandoc/blob/master/src/Text/Pandoc/Writers/LaTeX.hs?#L1048#L1053
when
\lstset{mathescape=true}code in two
$should not be converted, such as$x_1$should be\passthrough{\lstinline!$x_1$!}but in fact it is,
\passthrough{\lstinline!$x\_1$!}I think, when in mathescape=true, it should not convert the strings between two
$s.#4713
https://stackoverflow.com/questions/50898498/how-to-insert-in-lstinline/50919878#50919878
The text was updated successfully, but these errors were encountered: