auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be compl


From: Denis Bitouzé
Subject: Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX.
Date: Tue, 03 May 2022 14:16:39 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Le 03/05/22 à 14h07, Denis Bitouzé a écrit :

>   │   Here is an example of the
>   │   declaration I made for the `graphicx` package (the distribution in the
>   │   different classes being perhaps suboptimal) and you can see its effect
>   │   in the attached TeX and PDF files:

Sorry, I forgot the TeX file (below since I'm not sure attachments are
allowed on this list).

--8<---------------cut here---------------start------------->8---
\begin{filecontents}[overwrite]{lstlang0.sty}
\lst@definelanguage[graphicx]{TeX}[LaTeX]{TeX}{%
  % Control sequences names
  moretexcs={%
    
DeclareGraphicsExtensions,DeclareGraphicsRule,graphicspath,includegraphics*,%
    includegraphics,reflectbox,resizebox*,resizebox,rotatebox,scalebox,%
  },%
  % Keywords of class 1 : keywords that contain other characters (since of the
  % same class as the ones specified as 'otherkeywords')
  morekeywords={%
  },%
  % Keywords of class 2 : environments names
  morekeywords=[2]{%
  },%
  % Keywords of class 3 : mandatory arguments (not environments) & optional
  % arguments which are keys (in key=value)
  morekeywords=[3]{%
    draft,final,hiresbb,demo,setpagesize,nosetpagesize,dvips,xdvi,dvipdf,%
    dvipdfm,dvipdfmx,xetex,pdftex,luatex,dvisvgm,dvipsone,dviwindo,emtex,%
    dviwin,oztex,textures,pctexps,pctexwin,pctexhp,pctex32,truetex,tcidvi,%
    vtex,debugshow,hiderotate,hidescale,alt,bb,bbllx,bblly,bburx,bbury,%
    natwidth,natheight,hiresbb,pagebox,viewport,trim,angle,origin,width,%
    height,totalheight,keepaspectratio,scale,clip,draft,type,ext,read,%
    command,quiet,page,interpolate,decodearray,origin,x,y,units,%
  },%
  % Keywords of class 4 : values of keys (in key=value)
  morekeywords=[4]{%
    mediabox,cropbox,bleedbox,trimbox,artbox,true,false,%
  },%
  % Keywords of class 5 : arguments specifications (after ":" in expl3 syntax)
  morekeywords=[5]{%
  },%
  % Keywords of class 6 : current package name (and possibly derived packages)
  morekeywords=[6]{%
    graphicx,%
  },%
  % otherkeywords={},%
  % alsoletter={},%
  % alsodigit={},%
  sensitive,%
}[keywords,tex,comments]%
\end{filecontents}

\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{listings}
\usepackage{xcolor}

\colorlet{texcs}{blue}
\colorlet{comment}{gray}
\colorlet{argument_specification_separator}{red}
\colorlet{argument_specification}{cyan}
\colorlet{mandatory_argument}{purple}
\colorlet{environment}{teal}
\colorlet{key}{mandatory_argument}
\colorlet{value}{violet}
\colorlet{optional_argument}{key}
\colorlet{math}{green!50!black}

\lstdefinestyle{latex_listings_style}{
  basicstyle=\ttfamily,
  language=TeX,%
  alsolanguage=[primitive]TeX,%
  alsolanguage=[common]TeX,%
  alsolanguage=[plain]TeX,%
  alsolanguage=[LaTeX]TeX,%
  alsolanguage=[AlLaTeX]TeX,%
  texcsstyle=*\color{texcs},
  commentstyle=\color{comment}\itshape,
  keywordstyle=    \color{argument_specification_separator},
  keywordstyle={[2]\color{environment}},
  keywordstyle={[3]\color{key}},
  keywordstyle={[4]\color{value}},
  keywordstyle={[5]\color{argument_specification}},
  keywordstyle={[6]\color{key}},
  frame=single,
  literate=*%
  {\\\\}{{{\color{texcs}\textbackslash\textbackslash}}}{2}%
  {\\[}{{\textcolor{math}{\textbackslash[}}}{2}%
  {\\]}{{\textcolor{math}{\textbackslash]}}}{2}%
  {$}{{\textcolor{math}{\$}}}{1}%$
}

\lstset{style=latex_listings_style}

\begin{document}

\section{Without declaration for graphicx}

\begin{lstlisting}
\begin{figure}[ht]
  \centering
  \includegraphics[pagebox=trimbox,clip=false,height=6cm]{example-image-a}
  \caption{Image A}
  \label{image-a}
\end{figure}
\end{lstlisting}

\section{With declaration for graphicx}

\lstset{alsolanguage=[graphicx]TeX}

\begin{lstlisting}
\begin{figure}[ht]
  \centering
  \includegraphics[pagebox=trimbox,clip=false,height=6cm]{example-image-a}
  \caption{Image A}
  \label{image-a}
\end{figure}
\end{lstlisting}
\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
--8<---------------cut here---------------end--------------->8---
-- 
Denis



reply via email to

[Prev in Thread] Current Thread [Next in Thread]