lstlisting over whole text width in twocolumn article in latex - latex

I have an article in latex that has two columns. I am also using the lstlisting package to display code, and want the code two span over both columns similar to how \begin{figure*} works. If I place the listing in \onecolumn \twocolumn the listing is placed on a page by its own, but I would like the listing on the same page as text.
\documentclass[APA,STIX2COL]{WileyNJD-v2}
\lstdefinestyle{basic}{
numbers= none,
numberstyle=\scriptsize,
basicstyle=\ttfamily\scriptsize,
tabsize=2,
breaklines=true,
backgroundcolor=\color{black!10}
}
\begin{document}
\begin{lstlisting} [style=basic,float,floatplacement=htbp]
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
\end{lstlisting}
\end{document}
Document class can be found here https://www.overleaf.com/latex/templates/a-demonstration-of-the-latex-class-file-for-wiley-njd-journals/bfwqvgnbgcjc

Use Figure. For example:
\begin{figure*}[t]
\begin{lstlisting}
......
......
\end{lstlisting}
\end{figure*}

Related

Repeat cursor text in a custom Emmet snippet

I want to create a snippet where the the text I type at the first cursor position gets used multiple times. I thought I could do it this way by repeating a cursor position number but it just treats the other ones as independent cursor positions. I don't see anything in the documentation about this.
Here is an example of what I would like to work:
<template id=${1}>
This is a ${1}!
</template>
<style>
#${1} {${2}}
</style>
Here is my Emmet snippets file used in VS Code:
{
"html": {
"snippets": {
"test": "test[id=${1}]>{This is a ${1}.}"
}
}
}
When I use the 'test' snippet it puts the cursor at the first ${1} but anything I type is not reflected in the second ${1} it stays empty.
It depends on editor you’re using. If your editor fully supports text fields (like Sublime Text, VSCode) the example above should work, all ${N} with same N should be connected.

Styling excel in Laravel with Laravel Excel

Learning Laravel, I face now Excel export.
Searching in the Intenet Laravel Excel (docs.laravel-excel.com) seems to be the better choice, but I'm findind it very difficult to style the sheets (colors, fonts, sizes, etc.)
I'm using global event listeners in my AppServiceProvider:
Sheet::listen(AfterSheet::class, function () {
Sheet::macro('color_tab', function (Sheet $sheet, string $color) {
$sheet->getDelegate()->getTabColor()->setRGB($color);
});
});
And then I use it in my Export class:
...
public function __construct($color) {
$this->color = $color;
}
...
use RegistersEventListeners;
...
public static function afterSheet(AfterSheet $event) {
// this is an error because it's a static method!
$event->sheet->color_tab($this->color);
}
The problem is that I have to color the tab whit the color given in the constructor, but I can't because all these method for styling the Excel are static.
How can I do this?
Is there another good library to export Excel? With an easier way of do the styling.
Thanks!
Finally I decided to use directly PhpSpreadSheet library whithout using wrapper Laravel Excel

Mathjax not rendering latex formula

Within my rails application I use mathjax (TEX-AMS_HTML) to render latex formulas.
When entering formulas in a comment I use the codecogs Equation Editor with TinyMCE.
My current mathjax config ontop of (TEX-AMS_HTML) is:
"HTML-CSS": {linebreaks: { automatic: true, width: "container" }},
displayAlign: "left",
extensions: ["tex2jax.js","MathMenu.js","MathZoom.js"],
jax: ["input/TeX","output/HTML-CSS"],
TeX: { extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"] },
tex2jax: { ignoreClass: "w1", processClass: "active|comments-content" }
My problem is that some formulas are not rendering out, consider the following:
\[ foo\textup{bar} \]
This renders foo \textup bar. I have also noticed some symbols rendering textually such as:
\[ \AE \SS \]
This would render \AE \SS instead of the appropriate symbols.
I have tried switching to SVG, adjusting inline/display settings and cannot solve this.
Anyone have some idea as to why this is happening?
EDIT: Here is a contained example
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Mathjax</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
"HTML-CSS": {linebreaks: { automatic: true, width: "container" }},
displayAlign: "left",
extensions: ["tex2jax.js","MathMenu.js","MathZoom.js"],
jax: ["input/TeX","output/HTML-CSS"],
TeX: { extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"] },
tex2jax: { ignoreClass: "w1", processClass: "active|comments-content" }
});
</script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body>
<div id="wrapper">
<div id="main">
<div class="w1">
<div class="comments-content">
<p>\[foo\textup{bar}\AE\SS\]</p>
<p>\[K_{E}=\frac{1}{2}m(\frac{80}{3.6})^{2}\]</p>
</div>
</div>
</div>
</div>
</body>
</html>
Which renders as: http://i.imgur.com/bUJXZPX.png
Notice that whilst mathjax is working and correctly renders the 2nd line, the first line of latex is not escaped.
EDIT2 (22/06/2017):
"Note from the future: cdn.mathjax.org is nearing its end-of-life, check mathjax.org/cdn-shutting-down for migration tips (and perhaps update your answer for future readers)" - Thanks to user Peter Krautzberger
Basically this means the cdn used in my code example will need to be replaced with a localised version of mathjax.
The macros \textup, \AE, and \SS are not part of the default MathJax TeX macros and are not defined in your inline configuration, which is why the rendering in the image has them marked in red.
You'll see a more specific error if you remove the noundefined and noerrors extensions from your configuration -- which are also in the combined configuration TeX-AMS_HTML, so you'll need to drop that as well; as you can see from the link, your inline configuration entails all of TeX-AMS_HTML. (In production, it's preferable to use a combined configuration file since they load as a single large file.)
For a list of all default MathJax macros, see http://docs.mathjax.org/en/latest/tex.html#supported-latex-commands.
For how to define macros in MathJax, see https://tex.stackexchange.com/questions/139699/equivalent-of-mathup-for-upright-text-in-math-mode. From there an example:
MathJax.Hub.Config({
TeX: {
Macros: {
RR: "{\\bf R}",
bold: ["{\\bf #1}",1]
}
}
});
i.e., add a Macros block to the TeX block in your configuration.
(A particular case is\textup, which is a LaTeX text mode macro and MathJax focuses on math mode. Depending on the use case, the math equivalent might be \text{}, \mathrm{}, or something else, see this TeX.SE questions. Of course you can define \textup to be whatever you like but you might run into trouble backporting content to real TeX).

Formatting errorindicator

I need to format the errrorindicator depending on the textfields stylename. I couldn't find any css rule which takes the v-errorindicator style in dependence of a stylename for the textfield e. g.
.my-stylename-for-textfield .v-errorindicator {
style: xxx;
}
Does someone know a posibility?
Best regards
Bernhard
You can't style the errorindicator depending on your textfield style, you can style it depending on your overall theme name.
What I mean is that, Vaadin will generate a CSS file that's specific to your theme name, wihch you specify in you main UI:
#Theme("mytheme")
public class MyVaadinUI extends UI {
//....
And generates a CSS that looks like the following:
.mytheme .v-textfield {
text-align: left;
}
So you need to style your errorindicator specifying the name of your theme and the CSS hierarchy, which in your case is under the textfield:
.mytheme .v-textfield .v-errorindicator {
color: blue;
}
If you need more info on how to use Vaadin themes, check out the Theme chapter in the Vaadin book.

Insert an HTML heading on each pages in a while PHP for print

My question is a bit hard to explain but there I go..
I have a document generated in a WHILE (php) from a MySQL request and it does ~ 10 pages when I press Ctrl+P.
Demo source : http://3ansdemulti.com/dev/print.htm
As you can see, I would like to know if it is possible to configure dynamics pages with the HEADER on top of each PRINT page..
I know I can use the page-break-before on the element but how could I know how to determine where the page should break?
If you need more information, just ask me! I am open to discussions.
Use fPDF....
<?php
require('fpdf.php');
class PDF extends FPDF
{
// Page header
function Header()
{
// Logo
$this->Image('logo.png',10,6,30);
// Arial bold 15
$this->SetFont('Arial','B',15);
// Move to the right
$this->Cell(80);
// Title
$this->Cell(30,10,'Title',1,0,'C');
// Line break
$this->Ln(20);
}
// Page footer
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
//YOUR LOOP GOES HERE AND DEPENDING ON HOW MANY ITEMS FIT ON A PAGE,
//YOU ADD NEW PAGE...AND CALL THE HEADER AND FOOTER EACH TIME....
//DOCUMENTATION CAN BE FOUND ON THE SITE...
?>
www.fpdf.org
Just download the library and give it a go, it's the way better option for printable/emailable documents.

Resources