Closed ghost closed 8 years ago
Thanks for the report, @Rdbllx, but I'm not really sure I understand the situation -- I see the snippets dropdown just fine when I edit the text in a latex file (even between two $ $). To help us understand, can you share more details, as suggested by these guidelines?
Which version of Atom are you using? Which OS and version? Can you provide a latex file where this is happening and the contents of your local snippets.cson file? Can you share a GIF which clearly demonstrates the problem? Can you reproduce the problem in safe mode?
Thanks for your answer. Yes I'm sorry for this lack of information. I use the version1.0.19 of Atom on windows 7 .
Here is the content of the file snippets.cson:
###################################################################LaTeX##########################################################
# Document type :
'.text.tex.latex':
'document':
'prefix': 'document'
'body': '\\\\documentclass[a4paper, 12]{article} \n\n\\\\usepackage[utf8,utf8x]{inputenc}\n\\\\usepackage[french]{babel}\n\\\\usepackage{fancyhdr}\n\\\\usepackage[T1]{fontenc}\n\\\\usepackage{graphicx}\n\\\\usepackage{color}\n\\\\usepackage{perpage}\n\\\\usepackage{amsmath,amsfonts,amssymb}\n\\\\usepackage{array}\n\\\\usepackage{numprint}\n\\\\usepackage{sistyle}\n\\\\usepackage{listings}\n\\\\MakePerPage{footnote} \n\\\\begin{document} \n\\\\title{\\\\textbf{${1:Titre} }} \n\\\\author{Raphaël Paegelow} \n\\\\date{\\\\today} \n\\\\maketitle\n\\\\vspace{1cm} \n\n
$2
\n\n\n\\\\end{document}
'
# Bloc définition :
'Définition':
'prefix': 'def'
'body': """\\\\begin{description}\n\t\\\\item $\\\\bullet$ Définition:~~\\\\\\\\
\n \t \\\\fbox{\\\\parbox{\\\\linewidth\\\\fboxrule\\\\fboxsep}{${1:définition}}}\n\\\\end{description} $2"""
# Bloc propriété :
# Bloc citation :
'Citation':
'prefix': 'quote'
'body': '\\\\begin{center}\n\t\\\\textcolor{green}{"${1:citation}"} \n \\\\end{center}$2'
# écrire en gras :
'gras':
'prefix': 'gras'
'body': "\\\\textbf{${1:txt}}$2"
#écrire en italique :
'italique':
'prefix': 'italique'
'body': '\\\\textit{${1:txt}}$2'
# souligner :
'souligner':
'prefix': 'souligner'
'body': '\\\\underline{${1:txt}}$2'
#écrire en rouge :
'rouge':
'prefix': 'rouge'
'body': '\\\\textcolor{red}{${1:text}}$2'
#passer à la ligne :
'Saut de ligne':
'prefix': 'sautdeligne'
'body': '\\\\vspace{0.25cm}\n$1'
# Maths :
'Ensemble C':
'prefix': 'cmath'
'body': '\\\\mathbb{C} $2'
'Ensemble R':
'prefix': 'rmath'
'body': '\\\\mathbb{R} $2'
'Ensemble Z':
'prefix': 'zmath'
'body': '\\\\mathbb{Z} $2'
'Ensemble N':
'prefix': 'nmath'
'body': '\\\\mathbb{N} $2'
'Displaymath':
'prefix': 'dispmath'
'body': """\\\\[
${1:écrire une équation détachée du texte}
\\\\]
$2 """
'math':
'prefix': 'math'
'body': '$\\\\displaystyle ${1:écrire une équation mélangée au texte} $'
'Ensemble Sn':
'prefix': 'permmaths'
'body': '\\\\mathfrak{S}_n'
'entier de tant à tant':
'prefix': 'entierentre'
'body': '[\\\\![$1;$2]\\\\!]$3'
'définir une fonction':
'prefix': 'fct'
'body': """\\\\begin{displaymath}
${1:nom de la fct}:
\\\\left|
\\\\begin{array}{rcl}
${2:Ensemble de départ} & \\\\longrightarrow & ${3:Ensemble d'arrivée} \\\\\\\\
${4:variable} & \\\\longmapsto & ${5:expression} \\\\\\\\
\\\\end{array}
\\\\right.
\\\\end{displaymath}\n$6"""
#insérer une image :
'insérer image':
'prefix': 'insererimage'
'body': '\\\\begin{center}\n\\\\includegraphics{${1:image}}\n\\\\end{center}\n$2'
#siècle :
'siècle':
'prefix': 'siecle'
'body': '\\\\textsc{\\\\romannumeral ${1:siècle en chiffre arabe}}\\\\textsuperscript{e}~siècle $2'
# encadrer :
'encadrer':
'prefix': 'encadre'
'body': '\\\\fbox{\\\\parbox{\\\\linewidth\\\\fboxrule\\\\fboxsep}{${1:écrire texte}}} $2'
###################################################################LaTeX##########################################################
And for example :
\documentclass[a4paper, 12]{article}
\begin{document}
$ \alpha $
\end{document}
When I type :
$ + a
I don't have the snippets dropdown. I made a gif if I'm not clear . I made the gif really fast ^^.
Thanks, @Rdbllx. Just to make sure I understand -- which snippets did you expect to see listed in a dropdown exactly, after pressing "a"? And did I understand correctly that you observe this problem only in some specific places in that file, but not all? Also, which package are you using for LaTeX support? Atom doesn't have a LaTeX language package bundled with it, so you're using some other package for this -- can you clarify which one?
I expected to see \alpha by pressing tab. I observe this problem only when I'm writting in latex beetwen $, [ ... so when I'm writting maths. I use two packages: language latex: https://atom.io/packages/language-latex latex: https://atom.io/packages/latex
Same problem here on OS X 10.11.1, with atom version 1.1.10 and the same packages as Rdbllx.
The snippets dropdown does not work in a math environment (between $ $, \begin{align*}, [ ] ), but I do get the the dropdown list if I type anywhere else in the document.
The problem is only inside a math environment, inside a \begin{proof} the dropdown list works fine.
I am in the following scope when I'm working inside a math environment:
Some snippets do work there (for instance: left, right, console), but the latex snippets (the snippets included in the language-latex doesn't work). Maybe the editor picks the snippets for the wrong scope?
Hi djcol, have you pull this problem of? Thanks for your support.
Thanks for helping me reproduce this problem, @Rdbllx and @djcol.
So, I think I see why that's happening. The part within dollar signs $ $
seems to be tagged with a string scope by the language-latex package. And as far as I can tell, snippets are intentionally not included for comment
and string
scopes:
You will see the same behavior if you write a string var foo = " "
in JavaScript, place the cursor between the quotes, and try to get the snippets to show. It won't work because it's a string
scope. Still, you should be able to expand snippets (they work normally for me if I press tab
), it's just that they're not shown.
I'm going to close this since it seems that the behavior is intentional and is not related to this package. If you'd like this behavior to change, you could either ask the author of the language-latex package to change the scope for that part or open an issue in https://github.com/atom/autocomplete-snippets to request the behavior to be changed. If you do that, make sure you @-mention @benogle who made that change in https://github.com/atom/autocomplete-snippets/commit/28a0af0935baf4e26ca95d4e606dbb5dc53a6bbc.
I hope these notes are helpful!
Thanks for you answer.
The autocomplete is pretty useless in LaTeX if it doesn't work in math mode, because outside the math mode you are just typing text. Also there are a lot of snippets for mathematical symbols, so I think the intention of language-latex was that I should work in math mode.
It is easy to change the scope ourself @izuzak ? There is already an issue for this in the language-latex package (https://github.com/area/language-latex/issues/56), but the package hasn't been updated for months, and it sounds like it is easy to fix.
It is easy to change the scope ourself @izuzak ?
I can't think of an easy way to do that.
There is already an issue for this in the language-latex package (area/language-latex#56), but the package hasn't been updated for months, and it sounds like it is easy to fix.
Instead of waiting for that issue to be fixed, you could also:
1) Fork the package, change the behavior, and publish a new package with those changes, or
2) Add some custom code to your init.coffee file which removes all those string scopes in latex files. (see https://atom.io/docs/latest/hacking-atom-the-init-file) I haven't tried doing that myself before, so I can't offer any specific guidance on this.
I decided to fork the package and change the so-called behaviour, but how could I change it?
I just discovered that for me (Atom 1.12.7 on macOS 10.12.2) I'm able to trigger snippets within a $ ... $
block by pressing tab twice in a row.
Hello everyone, I need some help. I can't use snippets when I'm writting maths in latex. When I'm writting something between $ $ I can't see the drop-down menu for the snippets. The snippets are working but I find that without this menu it's really hard to remember. What can I do to fix it ? Thanks in advance for your answers