Can you please help me to find the error? I think it's ok the first part, but i can't find the error with the equation that should be a system.
'''\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\title{Test di \LaTeX del Laboratorio di Comunicazione
mediante Calcolatore}
\author{Sara Pia Ciccotosto \\
\textbf{s.ciccotosto#studenti.unipi.it}}
\begin{document}
\maketitle
\section{Teorema del laboratorio}
\subsection{ L’enunciato classico}
\paragraph{Scopo di queste note `e dimostrare in modo formale un risultato noto in letterature come \textit{Teorema del Laboratorio}. Si tratta di un risultato che ha un ruolo
fondamentale nella trattazione analitica di alcuni problemi di Cauchy, come il
seguente:
\begin{equation}
\begin{cases}
\frac{dy(x)}{dx} = 1+x^2 y(x) \\
y(0)=0
\end{cases}
\end{equation}'''
this is the output:
Runaway argument?
{Scopo di queste note `e dimostrare in modo formale un risultato noto\ETC.
! File ended while scanning use of \#xdblarg.
<inserted text>
\par
<*> "./test lcmc.tex"
?
and in "Error, warnings and badboxes" is written "File ended while scanning use of #xdblarg"
Thank you!
Related
For markdown, with Latex, I wrote a convenient command :
\newcommand{\mauve}[1]{\textcolor{Purple}{#1}}
\newcommand{\fonction}[1]{\begingroup\small\mauve{\texttt{#1}}\endgroup}
\newcommand{\cadreGris}{\renewtcolorbox{quote}{colback=darkgray!5!white,arc=0pt,outer arc=0pt,boxrule=0pt,lowerbox=invisible,code={\tcbset{enlarge left by=0cm}}}}
\newcommand{\code}{\begingroup\cadreGris\footnotesize}
that helps me formatting my source code in markdown that way:
On peut rajouter aux périodes des durées avec \fonction{plusYears(...)}, \fonction{plusMonths(...)}... ou en retrancher avec \fonction{minusDays(...)}...
- la classe \fonction{Duration}...
\code
> ```scala
> import java.time.Duration
> java.time.temporal.ChronoUnit
>
> Duration.of(10192927, ChronoUnit.MILLIS) // PT2H49M52.927S
> ```
\endgroup
Il est possible d'utiliser les méthodes \fonction{toHours()}, \fonction{toDays()}... Mais attention : elles retournent des nombres entiers. Ci-dessus, un `getDays()` renverra 0, car il y a 0 jours... et 2 heures.
Which produces this result I enjoy:
But is there a way I could create a new command, for example \scala,
that would perform:
\code
> ```scala
and then an \endcode that would produce:
> ```
\endgroup
Meaning : is there a way to mix blocks declaration of "markdown kind" and latex commands in a command definition?
I have the following .Rnw file:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{multicol}
\begin{document}
\begin{multicols}{2}
\hskip-3.5cm\begin{tabular}{|l|}
\hline
\cellcolor[RGB]{0,0,140}{\large\textbf{\textcolor{white}{Bill To: }}}\\
\hline
\textbf{
"asdf"
}\\
\\[-1em]
\textbf{asdf#asdf.com} \\
\hline
\end{tabular}
\hskip6cm\begin{tabular}{|l|l|}
\hline
Date: & 05/31/2018 \\
\hline
Invoice \#: & 1234asdf \\
\hline
\end{tabular}
\end{multicols}
\end{document}
which gives me the expected pdf:
However, when I replace the "asdf" with R code:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{multicol}
\begin{document}
\begin{multicols}{2}
\hskip-3.5cm\begin{tabular}{|l|}
\hline
\cellcolor[RGB]{0,0,140}{\large\textbf{\textcolor{white}{Bill To: }}}\\
\hline
\textbf{
<<asdf>>=
cat("asdf")
#
}\\
\\[-1em]
\textbf{asdf#asdf.com} \\
\hline
\end{tabular}
\hskip6cm\begin{tabular}{|l|l|}
\hline
Date: & 05/31/2018 \\
\hline
Invoice \#: & 1234asdf \\
\hline
\end{tabular}
\end{multicols}
\end{document}
I get the following error:
File ended while scanning use of \#xverbatim
Looking at the generated .tex file, this is the relevant part:
\textbf{
\begin{knitrout}
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
\begin{alltt}
\hlkwd{cat}\hlstd{(}\hlstr{"asdf"}\hlstd{)}
\end{alltt}
\begin{verbatim}
## asdf
\end{verbatim}
\end{kframe}
\end{knitrout}
}\\
and this is what the .log file says:
Runaway argument?
#### asdf \end {verbatim} \end {kframe} \end {knitrout} \check#icr \expandafte
r \ETC.
! File ended while scanning use of \#xverbatim.
<inserted text>
\par
<*> test2.tex
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.
! Emergency stop.
<*> test2.tex
What am I doing wrong?
By default, R output is wrapped in a LaTeX verbatim environment, and you can't put one of those inside \textbf. There are a couple of different approaches to fix this.
The simplest is just to use the chunk option results='asis', i.e.
\textbf{
<<asdf,results='asis',echo=FALSE>>=
cat("asdf")
#
}
This will prevent knitr from adding the environment around the output; the LaTeX code will just be
\textbf{
asdf
}
which should be fine.
If you want the default formatting but just want to change the font or style of text, things are harder. You need to tell knitr to use a different environment instead of verbatim, e.g. the Verbatim environment provided by the fancyvrb package. You can do this by changing the output hook. For example, this should work
% in the preamble:
\usepackage{fancyvrb}
<<include=FALSE>>=
oldhook <- knitr::knit_hooks$get("output")
bold <- function(x, options)
paste0("\\begin{Verbatim}[fontseries=b]\n", x, "\\end{Verbatim}")
#
% in the body:
<<asdf,echo=FALSE>>=
knitr::knit_hooks$set(output = bold)
cat("asdf")
#
% Optionally restore the old hook...
<<include=FALSE>>=
knitr::knit_hooks$set(output = oldhook)
#
However, it doesn't always work, because some options (like fontseries=b) conflict with settings that knitr makes. You can change to italic (using fontshape=it), but not to bold. So stick with the first suggestion.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
An interlinear gloss can be used to layout a translation of a document.
http://en.wikipedia.org/wiki/Interlinear_gloss
Usually this is done word-by-word or morpheme-by-morpheme. However, I would like to do this in a different way, translating entire paragraphs at a time. The following link and image is an example of what I want done, though I want to do it for a different text which is larger.
http://www.optimnem.co.uk/learning/spanish/three-little-pigs.php
For now I am not interested in taking into account the order of words or phrases that change order between languages. That is, I don't mind if the words in the paragraph are not aligned or if the length of one paragraph is much longer than the other, causing an overhanging line.
As far as I can tell, the following packages do not meet my needs:
covingtn.sty
cgloss4e.sty
gb4e.sty
lingmacros.sty - shortex
Here is the english version:
In the heart of the forest lived three little pigs who were brothers. The wolf always was chasing them in order to eat them. In order to escape the wolf, the pigs decided to make a house each. The smallest made his from straw, to finish first and go out to play. The middle one constructed a cottage from wood. Seeing that his little brother had finished already, he hurried to go and play with him. The oldest worked on his house of brick. 'You'll soon see what the wolf does with your houses,' he scolded his brothers but they were having a great time.
Here is the spanish version:
En el corazón del bosque vivían tres cerditos que eran hermanos. El lobo siempre andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron hacerse una casa. El pequeño la hizo de paja, para acabar antes y poder irse a jugar. El mediano construyó una casita de madera. Al ver que su hermano perqueño había terminado ya, se dio prisa para irse a jugar con él. El mayor trabajaba en su casa de ladrillo. - Ya veréis lo que hace el lobo con vuestras casas - riñó a sus hermanos mientras éstos se lo pasaban en grande.
I don't want to do it manually like this:
\documentclass{article}
\usepackage[margin=1in, paperwidth=8.5in, paperheight=11in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{url}
\begin{document}
\noindent
\url{http://www.optimnem.co.uk/learning/spanish/three-little-pigs.php}\\
\\
\indent
En el corazón del bosque vivían tres cerditos que eran hermanos. El lobo siempre\\
\indent
In the heart of the forest lived three little pigs who were brothers. The wolf always\\
\\
%
andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron\\
was chasing them in order to eat them. In order to escape the wolf, the pigs decided to\\
\\
%
hacerse una casa. El pequeño la hizo de paja, para acabar antes y poder irse a jugar.\\
make a house each. The smallest made his from straw, to finish first and go out to play.\\
\\
%
El mediano construyó una casita de madera. Al ver que su hermano perqueño había\\
The middle one constructed a cottage from wood. Seeing that his little brother had\\
\\
%
terminado ya, se dio prisa para irse a jugar con él. El mayor trabajaba en su casa de\\
finished already, he hurried to go and play with him. The oldest worked on his house of\\
\\
%
ladrillo. - Ya veréis lo que hace el lobo con vuestras casas - riñó a sus hermanos\\
brick. 'You'll soon see what the wolf does with your houses,' he scolded his brothers\\
\\
%
mientras éstos se lo pasaban en grande.\\
but they were having a great time.\\
\\
\end{document}\\
I would like to use a package or a macro to automatically have the english and spanish texts interspersed with line breaks when the end of the line has been reached for each. How can I layout this simple dual-line biligual paragraph in Latex in a more automated way (without manually adding line breaks)?
The following hack may help you achieve your goal. It's based on the idea of a zero-height minipage to overlap two triple-spaced minipages.
I'll use placeholders for the English and Spanish text (\english and \spanish respectively). Also, be sure to include the setspace package:
\usepackage{setspace}
\def\english{In the heart of the forest lived three little pigs who were brothers. The wolf always was chasing them in order to eat them. In order to escape the wolf, the pigs decided to make a house each. The smallest made his from straw, to finish first and go out to play. The middle one constructed a cottage from wood. Seeing that his little brother had finished already, he hurried to go and play with him. The oldest worked on his house of brick. 'You'll soon see what the wolf does with your houses,' he scolded his brothers but they were having a great time.}
\def\spanish{En el corazón del bosque vivían tres cerditos que eran hermanos. El lobo siempre andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron hacerse una casa. El pequeño la hizo de paja, para acabar antes y poder irse a jugar. El mediano construyó una casita de madera. Al ver que su hermano perqueño había terminado ya, se dio prisa para irse a jugar con él. El mayor trabajaba en su casa de ladrillo. - Ya veréis lo que hace el lobo con vuestras casas - riñó a sus hermanos mientras éstos se lo pasaban en grande.}
By giving the top block a height of 0pt we allow for the next minipage to overlap it.
\begin{minipage}[t][0pt]{\linewidth}
\setstretch{3}
\english
\end{minipage}
\begin{minipage}[t]{\linewidth}
\setstretch{3}
\spanish
\end{minipage}
The primary One of the problems with this idea is that if the zero-height section is longer than the regular section, then you'll have some lingering overlapping text to deal with. (Edit: This problem is addressed in the comment below, note that line-breaks will also be a serious drawback to this idea.)
The result (in part):
I don't think there is a package to do what you want, but it is possible to implement this yourself using \vsplit, which is well documented in Tex by Topic (availble for free download, or in the dead-tree edition via Lulu). The basic idea is
You define two vboxes, one for the English, one for the Spanish, and you want to take out the contents one line at a time. Call these vboxes \ENbox and \ESbox;
You need to determine the correct vertical dimension to use: this might be \lineheight, or you might need a different value, you will have to experiment. Assuming \lineheight is right ...
... then you can get the next line of English using \setbox\nextline=\vsplit\ENbox to \lineheight, which you can output using \unvbox\ENbox, then likewise the next line from \ESbox, then some vertical space for the intergloss gap;
Then you need to test the loop, which you can do by querying the vertical heights, using \ht, of \ENbox and \ESbox. This bit will be fiddly.
All-in-all, this will be somewhat tricky coding: good luck, and don't hesitate to ask questions here if you run into difficulties.
Postscript This is obviously much more work than Geoff's much simpler solution, which for some reason I hadn't seen when I wrote this, but it should be more flexible if you want to fiddle with it.
If you want to interlace Spanish and English paragraphs, and have them line up approximately correctly, then what you want is to write your translations word-by-word (or several words by several words), and use a gloss package that can wrap long sentences. I've done this before using gloss.sty. An example of its use(the goal was to gloss each word with its part of speech):
\gloss Both knowledge and wisdom extend man's reach. Knowledge led to
cjc nn0 cjc nn0 vvb {nn0 pos} {nn0 pun} nn0 vvd prp
\gloss computers, wisdom to chopsticks. Unfortunately our association is
{nn2 pun} nn0 prp {nn2 pun} av0 dps nn1 vbz
\gloss overinvolved with the former. The latter will have to wait for a
ad0 prp at0 {nn0 pun} at0 nn0 vm0 vhb to0 vvb avp at0
\gloss more sublime day.
av0 aj0 {nn1 pun}
\unhbox\gline
The package lines things up words from the first language with words from the second "language" using spaces. To line up multiple words in one language with a single word (or multiple words) from the other language, use braces to group the multiple words. Though the lines here are interlaced, this is just for my editing convenence. You could write really long lines if you wanted to, and the gloss algorithm will wrap them properly.
I've also used a two-column paragraph-by-paragraph approach using the parallel package.
put an extra line break in between each set of lines:
%
andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron
was chasing them in order to eat them. In order to escape the wolf, the pigs decided to
%
My equation is very long. How do I get it to continue on the next line rather than go off the page?
If your equation does not fit on a single line, then the multline (note that that's multline without an "i", not "multiline") environment probably is what you need:
\begin{multline}
first part of the equation \\
= second part of the equation
\end{multline}
If you also need some alignment respect to the first part, you can use split:
\begin{equation}
\begin{split}
first part &= second part #1 \\
&= second part #2
\end{split}
\end{equation}
Both environments require the amsmath package.
See also aligned as pointed out in an answer below.
Not yet mentioned here, another choice is environment aligned, again from package amsmath:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{aligned}
A & = B + C\\
& = D + E + F\\
& = G
\end{aligned}
\end{equation}
\end{document}
This outputs:
Without configuring your math environment to clip, you could force a new line with two backslashes in a sequence like this:
Bla Bla \\ Bla Bla in another line
The problem with this is that you will need to determine where a line is likely to end and force to always have a line break there. With equations, rather than text, I prefer this manual way.
You could also use \\* to prevent a new page from being started.
If it is inline equation, then use \allowbreak. Use it like:
$x_1,x_2,x_3,\allowbreak x_4,x_5$.
Latex will break equation in this place only if necessary.
There are a couple ways you can deal with this. First, and perhaps best, is to rework your equation so that it is not so long; it is likely unreadable if it is that long.
If it must be so, check out the AMS Short Math Guide for some ways to handle it. (on the second page)
Personally, I'd use an align environment, so that the breaking and alignment can be precisely controlled. e.g.
\begin{align*}
x&+y+\dots+\dots+x_100000000\\
&+x_100000001+\dots+\dots
\end{align*}
which would line up the first plus signs of each line... but obviously, you can set the alignments wherever you like.
I think I usually used eqnarray or something. It lets you say
\begin{eqnarray*}
x &=& blah blah blah \\
& & more blah blah blah \\
& & even more blah blah
\end{eqnarray*}
and it will be aligned by the & &... As pkaeding mentioned, it's hard to read, but when you've got an equation thats that long, it's gonna be hard to read no matter what... (The * makes it not have an equation number, IIRC)
I used the \begin{matrix}
\begin{equation}
\begin{matrix}
line_1 \\
line_2 \\
line_3
\end{matrix}
\end{equation}
multline is best to use. Instead, you can use dmath, split as well.
Here is an example:
\begin{multline}
{\text {\bf \emph {T(u)}}} ={ \alpha *}{\frac{\sum_{i=1}^{\text{\bf \emph {I(u)}}}{{\text{\bf \emph {S(u,i)}}}* {\text {\bf \emph {Cr(P(u,i))}}} * {\text {\bf \emph {TF(u,i)}}}}}{\text {\bf \emph {I(u)}}}} \\
+{ \beta *}{\frac{\sum_{i=1}^{\text{\bf \emph {$I_h$(u)}}}{{\text{\bf \emph {S(u,i)}}}* {\text {\bf \emph {Cr(P(u,i))}}} * {\text {\bf \emph {TF(u,i)}}}}}{\text {\bf \emph {$I_h$(u)}}}}
\end{multline}
This worked for me while using mathtools package.
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{equation}
\begin{multlined}
first term \\
second term
\end{multlined}
\end{equation}
\end{document}
Use eqnarray and \nonumber
example:
\begin{eqnarray}
sample = R(s,\pi(s),s') + \gamma V^{\pi} (s') \nonumber \\
\label{eq:temporal-difference}
V^{\pi}_{k+1}(s) = (1-\alpha)V^{\pi}(s) - \alpha[sample]
\end{eqnarray}
SIMPLE ANSWER HERE
\begin{equation}
\begin{split}
equation \\
here
\end{split}
\end{equation}
To solve this issue, I used the array environment inside the equation environment like this:
\begin{equation}
\begin{array}{r c l}
first Term&=&Second Term\\
&=&Third Term
\end{array}
\end{equation}
You do not need any extra package to do this:
\begin{equation}
\begin{gathered}
first formula\\
second formula
\end{gathered}
\end{equation}
How can I write "C++" in LaTeX so that the output looks nice. For example C$++$ doesn't look good: the plus signs are too big and there is too much space.
The standard solution for cases like this is to use verbatim:
\verb!C++!
I've been using the code below to typset a nice looking C++ in my Master-Thesis. The code has been copied verbatim from a german forum. You should be able to just copy-paste all the code in a new .tex-document and pick the relevant stuff for you...
\documentclass{article}
\usepackage{relsize}
\usepackage{lipsum}
%c from texinfo.tex
\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
%c C plus plus
\def\C++{%
\ifmonospace%
C++%
\else%
C\kern-.1667em\raise.30ex\hbox{\smaller{++}}%
\fi%
\spacefactor1000 }
%c C sharp
\def\Csharp{%
\ifmonospace%
C\#%
\else%
C\kern-.1667em\raise.30ex\hbox{\smaller{\#}}%
\fi%
\spacefactor1000 }
\begin{document}
\begin{center}
{\Huge C++ $\rightarrow$ \C++ \& \Huge C\# $\rightarrow$ \Csharp}\\
\bigskip
\ttfamily
{\Huge C++ $\rightarrow$ \C++ \& \Huge C\# $\rightarrow$ \Csharp}\\
\bigskip
\sffamily
{\Huge C++ $\rightarrow$ \C++ \& \Huge C\# $\rightarrow$ \Csharp}
\end{center}
\section{\C++}
\lipsum[1]
\subsection{\Csharp}
\lipsum[1]
\end{document}
You could try and use a typewriter font.
\texttt{C++}
I've found that the following gives good results:
\def\Cplusplus{C\raisebox{0.5ex}{\tiny\textbf{++}}}
This is what I used loooong time ago:
\newcommand*{\Cpp}{C\ensuremath{++}\xspace}
to be used like \Cpp (needs xspace package). But as you said, it is not really beautiful.
This answer, for the same question on the tex site, gives what I find to be a good looking way to this.
%C++
\newcommand\Cpp{C\nolinebreak[4]\hspace{-.05em}\raisebox{.4ex}{\relsize{-3}{\textbf{++}}}}
%C#
\newcommand\Csh{C\nolinebreak[4]\hspace{-.05em}\raisebox{.4ex}{\relsize{-3}{\textbf{\#}}}
There is a \cpluspluslogo command "with the ‘+’ signs properly positioned" in the package texlogos.
An other discussion on TeX - LaTeX Stack Exchange: Prettiest way to typeset “C++” (cplusplus)?.