Comments (17)
The breaklines
option now works for \mintinline
.
from minted.
@gembez The default breaklines
only inserts breaks at spaces. If you don't have spaces, you need to use breakanywhere
, or specify particular characters to break before/after with breakbefore
and breakafter
. Details are in the documentation.
from minted.
@gembez For all inline content: \setmintedinline{breaklines}
. For individual commands: \mintinline[breaklines]{<lang>}{<code>}
.
from minted.
@benkuly I was forgetting that all of the special breaklines
options like breakbefore
and breakafter
and breakanywhere
don't work with \mintinline
. Here's a patch you can add to your preamble that should get it working. You will want something like \mintinline[breaklines, breakafter=-]{xml}{spring-boot-starter-test}
. I will probably need to refine this a little before releasing it in a future version of minted
.
\usepackage{minted}
\makeatletter
\renewcommand{\minted@inputpyg}{%
\expandafter\let\expandafter\minted@PYGstyle%
\csname PYG\minted@get@opt{style}{default}\endcsname
\VerbatimPygments{\PYG}{\minted@PYGstyle}%
\ifthenelse{\boolean{minted@isinline}}%
{\ifthenelse{\equal{\minted@get@opt{breaklines}{false}}{true}}%
{\let\FV@BeginVBox\relax
\let\FV@EndVBox\relax
\def\FV@BProcessLine##1{%
\FancyVerbFormatLine{%
\FV@BreakByTokenAnywhereHook
\FancyVerbFormatText{\FancyVerbBreakStart##1\FancyVerbBreakStop}}}%
\minted@inputpyg@inline}%
{\minted@inputpyg@inline}}%
{\minted@inputpyg@block}%
}
\makeatother
You can change the symbol that appears at the break using breakaftersymbolpre
.
from minted.
By accident, I discovered a strange combination that worked. Up top, I declared \setmintedinline{breaklines}
but each time specify \mintinline[breakanywhere]{...}{...}
. A self-contained example is below:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{minted}
\usemintedstyle{borland}
\setmintedinline{breaklines} % necessary for breakanywhere to work later on.
\title{EECE5354 Computer Vision: Assignment 1}
\author{Zhanwen Chen}
\date{January 27, 2019}
\begin{document}
\maketitle
\section{Introduction}
This assignment requires implementation of three image processing functions: separation filter with a Gaussian kernel, and two more with my choosing. In addition, other deliverables include a function to limit all image processing functions to only process a sub-region specified by a rectangle, and an example video output with specific operations.
\vspace{5mm}
In my solution, I first refactored the assignment starter script, \mintinline[breakanywhere]{python}{testcv_mt_vid.py}, to use object-oriented approach where I replaced with state attributes all global variables that the program modifies during running.
\section{Implementation of Separation Filter}
1. \mintinline[breakanywhere]{python}{sepFilter2D()} with a Gaussian Kernel that you generate using \mintinline[breakanywhere]{python}{getGaussianKernel()}. (Note that you can get the same results using the module called \mintinline{python}{GaussianBlur()}. But I want you to use \mintinline{python}{sepFilter2D} with a Gaussian Kernel so that you learn how to apply an arbitrary separable filter to an image.)
\end{document}
from minted.
The following dependencies are used by every application: \mintinline[breaklines]{xml}{spring-boot-starter-web} and \mintinline[breaklines]{xml}{spring-boot-starter-test}.
doesn't seem to work for me. I get a Overfull \hbox (40.09329pt too wide) in paragraph
warning.
Best & thanks!
from minted.
@arch-linux-tux The code does usually work, but your particular example is failing due to TeX's hyphenation system. minted
uses fvextra
internally for the line breaking. The break itself uses \discretionary
, which involves TeX's hyphenation system. By default, hyphenation won't work for such a long string of text with only a single possible hyphenation point (the period in this case). You would need to modify hyphenation settings. Using something like \setlength{\rightskip}{0pt plus 1 fil}
works. However, this will change hyphenation for the rest of the document. To limit it to a single paragraph, you probably want something like this:
\begingroup
\setlength{\rightskip}{0pt plus 1 fil}
<paragraph with \mintedinline that won't normally break>
\endgroup
from minted.
The "I want automatic line breaks for long lines" applies to environments only. I've clarified the docs.
The current implementation of \mintinline
uses BVerbatim
from fancyvrb
. This gives inline verbatim content, but will not allow line wrapping. The standard \verb
behaves the same way (for example, see this).
It seems possible to do what you want, but it will require a completely new version of BVerbatim
to eliminate the \hbox
es etc. And eliminating those may introduce other issues. So it may be a while till I can get this working.
from minted.
Ok, thanks for the quick answer.
from minted.
@gpoore how can I define the option?
from minted.
I've the same problem as @gembez
His \mintinline[breaklines]{xml}{spring-boot-starter-test}
should be in a new line as well as a pure string spring-boot-starter-test
is.
from minted.
Hm okay, but this only works when I want to break within the \mintinline
. If I e.g. have a long class-name like \mintinline[breaklines]{java}{AbstractSecurityInterceptor}
I don't want a break within the name. I want it completely on a new line if it dont fit on the same line. But actually I get the message Underfull \hbox (badness 4819) in paragraph
. The command \emergencystretch 3em
helps that it is on a new line, but that is only a workaroud. Maybe I missed something?
from minted.
@benkuly If you're dealing with a case where a break within the \mintinline
isn't an option and you're getting \hbox
messages, then you will have to use paragraph-level commands like \emergencystretch
to get things to look acceptable. \mintinline
doesn't have any information about its position in the line or overall paragraph layout, so it can't really turn these kinds of things on automatically. At that point, dealing with \mintinline
is just like dealing with something like a very long number that can't be hyphenated, and thus requires manual adjustment to paragraph layout using \emergencystretch
, \sloppy
, or something similar, depending on the document context.
from minted.
Thank you very much 👍 👍
from minted.
When I try to use the code given by gpoore:
\usepackage{minted}
\makeatletter
\renewcommand{\minted@inputpyg}{%
\expandafter\let\expandafter\minted@PYGstyle%
\csname PYG\minted@get@opt{style}{default}\endcsname
\VerbatimPygments{\PYG}{\minted@PYGstyle}%
\ifthenelse{\boolean{minted@isinline}}%
{\ifthenelse{\equal{\minted@get@opt{breaklines}{false}}{true}}%
{\let\FV@BeginVBox\relax
\let\FV@EndVBox\relax
\def\FV@BProcessLine##1{%
\FancyVerbFormatLine{%
\FV@BreakByTokenAnywhereHook
\FancyVerbFormatText{\FancyVerbBreakStart##1\FancyVerbBreakStop}}}%
\minted@inputpyg@inline}%
{\minted@inputpyg@inline}}%
{\minted@inputpyg@block}%
}
\makeatother
This does not make \mintinline[breaklines, breakbefore=.]{java}{tesssssssssssssssssssssssssssssssssssssssssssssssssssst.breaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaak}
break for me. So it doesn't work for me.
Anyways, I can't find the word breakafter
in the code.
from minted.
What about documents with custom margins?
from minted.
@caniko2 Custom margins shouldn't affect breaklines
, unless the custom margins are used to define very narrow columns that make hyphenation difficult. In that case, you may need to work with breakbefore
, breakafter
, or custom hyphenation settings in addition to just using breaklines
. All line breaking is using TeX's normal hyphenation, so breaklines
should work anywhere that hyphenation would.
from minted.
Related Issues (20)
- Breaking line within \newmintinline throws error
- `linerange` to select the exact lines to output HOT 2
- `newmintedfile` env* to specify additional options HOT 9
- [bug] `gobble` results in malformed formatting, `autogobble` works HOT 5
- [show-&-tell] ad-hoc adoptations from a different style to another one. HOT 1
- [feature] Support for PDDL programming language HOT 2
- [bug][compatibility] `Verbatim` environment generated by `minted` with `mathescape` broken with `babel`'s `magyar.ldf` (Hungarian 🇭🇺 language) HOT 1
- JSX highlighting is not working in overleaf HOT 1
- breaksymbolleft flush with line numbers HOT 2
- Write env content to file HOT 2
- Failed Compilation with MikTeX on windows HOT 19
- Overfull hbox with `mintinline` and `breakanywhere` in enumerate environment HOT 1
- Escapeinside content is misplaced in pygtex file for nodejsrepl type HOT 7
- Because of changes in one of the most popular Python installer on Mac, doc needs an improvement (`pip3 install Pygments` doesn't work anymore) HOT 1
- file extension `lol' cannot be used twice HOT 3
- autogobble option not working for me HOT 12
- Can not compile via latexmk in Windows HOT 5
- Missing Pygments output; \inputminted... HOT 2
- [Feature request] named code segments HOT 1
- Get full timestamp in XeTeX through \creationdate HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from minted.