0

After this question answer How to use the standard - (hyphen) as the \hyp{} command from the hyphenat package?, I decided to not use that hack. Then, I am looking for an alternative to that.

On my case, using "= is almost as hard as \hyp{} because I write latex code on Sublime Text, and I use this package https://github.com/r-stein/sublime-text-latex-smart-quotes which does this:

enter image description here

i.e., when I press " is sends `` and '' according to where I am on the word: https://github.com/r-stein/sublime-text-latex-smart-quotes/issues/4

The only way to send " is by pressing Ctrl+L, L, ", which is as hard as have to type \hyp{}.

I love this feature of because I never have to use " unless I would like to do "=, but I prefer to keep the https://github.com/r-stein/sublime-text-latex-smart-quotes feature and use something else other than "=.

Can I bind it to something as handly as ´= (not `=)? Or do you suggest something else?

Then, I can use it like this something´=hyphenated, instead of something"=hyphenated

I tried doing this: \newcommand{´=}{\hyp{}} but latex did not liked it:

test1.tex: LaTeX Error: Missing \begin{document}.

Update 1

I found this question How to hyphenate a reference that has a lastname with a hyphen? suggesting this, but it had no effect:

\documentclass[10pt,a5paper,twoside]{article}
\usepackage{hyphenat}
\usepackage[english]{babel}

\defineshorthand{´=}{\hyp{}}

\begin{document}

\section{Show font}

    Tests.

    Encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding.

    Encoding´=encoding´=encoding´=encoding´=encoding´=encoding´=encoding´=encoding´=encoding´=encoding.

    Encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding.

\end{document}

enter image description here

Update 2

After reading http://linorg.usp.br/CTAN/macros/latex/required/babel/base/babel.pdf I managed to get this working:

\documentclass[10pt,a5paper,twoside]{article}
\usepackage{hyphenat}
\usepackage[english]{babel}

\useshorthands{"}
\defineshorthand{"=}{\hyp{}}

\begin{document}

\section{Show font}

    Tests.

    Encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding.

    Encoding"=encoding"=encoding"=encoding"=encoding"=encoding"=encoding"=encoding"=encoding"=encoding.

    Encoding´=encoding´=encoding´=encoding´=encoding´=encoding´=encoding´=encoding´=encoding´=encoding.

    Encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding.

\end{document}

enter image description here

But when using something like:

\useshorthands{´}
\defineshorthand{´=}{\hyp{}}

Latex throws this error:

Package babel Info: Making  an active character on input line 5.
test1.tex:5: LaTeX Error: Missing \begin{document}.
  • What comes after newcommand must be a macro. Hence the error. Have you considered using the package csquotes instead of using that plugin? – Weijun Zhou Apr 28 at 2:04
  • I did not have considered that package. I do know why, but I already have that package included on my thesis template, but seems not to be doing anything useful. Then, I think I will keep using Sublime Text with `` thing'' – user Apr 28 at 2:11
  • I am using it with \MakeOuterQuote{"} and I can type all the double quotes without problem. They are automatically matched and replaced with the correct (opening or closing) one. I seldom use single quotes but there is something similar in the document. – Weijun Zhou Apr 28 at 2:12
  • Check page 12 of the babel manual. You need \useshorthands* before you define a shorthand. – Weijun Zhou Apr 28 at 3:40
  • 1
    ´ is not an ascii char, it is U+B4, which in utf8 is encoded with two bytes (0xC2 0xB4). You can't use it for a shorthand. – Ulrike Fischer Apr 28 at 10:00
0
  1. I managed to create this shorthand with !-, but it is breaking words after ! alone. For example, This is! Sparta. will show as This is!Sparta.

  2. Then, instead of using !-, I think I will be using $- if this does not break anything else. This is breaking Latex text editor syntax parsing. They are thinking we are on math mode after using some word$-thing.

  3. Finally, using ~- does not break anything because even when using ~ alone, it works as indented It breaks when using ~--~ dashes.

  4. Maybe finally, using ~= does not break anything because even when using ~ alone, it works as indented:

\documentclass[10pt,a5paper,twoside]{article}
\usepackage{hyphenat}
\usepackage[english]{babel}

\useshorthands{~}
\defineshorthand{~-}{\hyp{}}

\begin{document}

\section{Show font}

    Tests.

    Encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding.

    Testing~This motherfoer1.

    Testing~ This motherfoer2.

    Encoding~-encoding~-encoding~-encoding~-encoding~-encoding~-encoding~-encoding~-encoding~-encoding.

    Encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding.

\end{document}

--> enter image description here


If someone knows how to create the shorthand ´=, please, share it!

  • As has been said in other comments, you need to use a basic ASCII character (ASCII code 0~126) as the prefix. The prefix you want to use simply won't work. – Weijun Zhou Apr 28 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.